MIC Examples

From SA-MP Wiki

Jump to: navigation, search

Contents

mic_admin


public OnPlayerCommandText(playerid,cmdtext[])
{
// BanLT(playerid,time)
if (strcmp("/ban ",cmdtext,true,5)==0)
{
new pid = strval(cmdtext[5]);
new tim = strval(cmdtext[7]);
BanLT(pid,tim);
return 1;
}
// UnBan(playerid)
if (strcmp("/unban ",cmdtext,true,7)==0)
{
UnBan(cmdtext[7]);
return 1;
}
// Pause(time);
if (strcmp("/pause ",cmdtext,true,7)==0)
{
new tim;
tim = strval(cmdtext[7]);
Pause(tim);
return 1;
}
// Silence(playerid)
if (strcmp("/mute ",cmdtext,true,6)==0)
{
new pid;
pid = strval(cmdtext[6]);
Silence(pid);
return 1;
}
// UnSilence(playerid);
if (strcmp("/unmute ",cmdtext,true,8)==0)
{
new pid;
pid = strval(cmdtext[8]);
UnSilence(pid);
return 1;
}
// Scan(playerid)
if (strcmp("/scan ",cmdtext,true,6)==0)
{
new pid;
pid = strval(cmdtext[6]);
Scan(pid);
return 1;
}
return 0;
}


mic_ammu

new AmmuLS;
public OnGameModeInit()
{
// EnableBlockAmmu
EnableBlockAmmu(1);
// CreateAmmu
AmmuLS = AddStatic(1,1,1,0,1,1,1);
// SetWeaponCost
SetWeaponCost(AmmuLS,11,130);
SetWeaponCost(AmmuLS,12,200);
SetWeaponCost(AmmuLS,13,390);
SetWeaponCost(AmmuLS,21,310);
SetWeaponCost(AmmuLS,22,220);
SetWeaponCost(AmmuLS,31,100);
SetWeaponCost(AmmuLS,32,275);
SetWeaponCost(AmmuLS,51,320);
SetWeaponCost(AmmuLS,61,450);
SetWeaponCost(AmmuLS,62,600);
SetWeaponCost(AmmuLS,71,1000);
SetWeaponCost(AmmuLS,72,1000);
return 1;
}
// OnPlayerEnterCheckpoint
public OnPlayerEnterCheckpoint(checkpointid,playerid){
if (checkpointid == Ammu1)
{
ShowAmmu(playerid,AmmuLS);
TogglePlayerControllable(playerid,0);
}
return 1;
}

mic_biz

new biz1;
new biz2;
public OnGameModeInit()
{
// AddStaticBiz
biz1 = AddStaticBiz(1958.3783, 1343.1572, 15.3746,1958.3783, 1343.1572, 18.3746,0);
biz2 = AddStaticBiz(4554.3783, 4545.1572, 4255.3746,454.3783, 684.1572, 455.3746,0);
new cost1;
// GetBizCost
GetBizCost(biz1,cost1);
// SetBizCost
SetBizCost(biz2,cost1+1000);
new string[256];
// GetBizInfo
GetBizInfo(biz1,"Owner",string);
// SetBizInfo
GetBizInfo(biz2,"Owner","Kapil_z");
return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp("/in",cmdtext,true)==0)
{
// SetPlayerInBiz
SetPlayerInBiz(playerid,biz2);
}
if(strcmp("/out",cmdtext,true)==0)
{
// SetPlayerInBiz
SetPlayerOutBiz(playerid,biz2);
}
}

mic_chat

public OnGameModeInit()
{
EnableChatSystem(1);
return 1;
}


public OnPlayerConnect(playerid)
{
SendMessage("Welcome to My Boom Boom Dhaam Dhaam server.");
return 1;
}

mic_data

public OnPlayerConnect(playerid)
{
new smoney[256],imoney;
new shealth[256],ihealth;

// LoadPlayer
LoadPlayer(playerid,"Money",smoney);
LoadPlayer(playerid,"Health",shealth);

imoney = strval(smoney); // converting strings to decimals
ihealth = strval(shealth);

GivePlayerMoney(playerid,imoney);
SetPlayerHealth(playerid,ihealth);

return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
new smoney[256],imoney;
new shealth[256],ihealth;

imoney = GetPlayerMoney(playerid);
GetPlayerHealth(playerid,ihealth);
valstr(smoney,imoney); // converting decimals to strings
valstr(shealth,ihealth);

// SavePlayer
SavePlayer(playerid,"Money",smoney);
SavePlayer(playerid,"Health",shealth);

return 1;
}

mic_gang

new gang[MAX_PLAYERS]


public OnPlayerCommandText(playerid,cmdtext[]){

if(strcmp(cmdtext,"/gang create",true,12)==0){
if(strlen(cmdtext)==12){
SendClientMessage(playerid,COLOR_BLUE,"USAGE: /gang create [name]");
}
else
{
gang[playerid] = CreateGang(cmdtext[13],GetPlayerColor(playerid));
}
return 1;
}

if(strcmp(cmdtext,"/gang join",true,10)==0){
if(strlen(cmdtext)==12){
SendClientMessage(playerid,COLOR_BLUE,"USAGE: /gang join [playerid]");
}
else
{
// CreateGang
new pid = strval(cmdtext[10]);
SetPlayerInGang(playerid,gang[pid]);
}
return 1;
}

if (strcmp(cmdtext,"/g",true,2){
new name[256];
new string[256];
new mygang;
// GetPlayerGangId
mygang = GetPlayerGangId(playerid);
GetPlayerName(playerid,name,256);
format(string,256,"%s: %s",name,cmdtext[3]);
// SendMessageToGang
SendMessageToGang(mygang,COLOR_GREEN,string);
return 1;
}
return 0;
}

mic_house

new house1;
new house2;
public OnGameModeInit()
{
// AddStaticHouse
house1 = AddStaticHouse(1958.3783, 1343.1572, 15.3746,1958.3783, 1343.1572, 18.3746,0);
house2 = AddStaticHouse(4554.3783, 4545.1572, 4255.3746,454.3783, 684.1572, 455.3746,0);
new cost1;
// GetHouseCost
GetHouseCost(house1,cost1);
// SetHouseCost
SetHouseCost(house2,cost1+1000);
new string[256];
// GetHouseInfo
SetHouseInfo(house1,"Owner",string);
// SetHouseInfo
GetHouseInfo(house2,"Owner","Kapil_z");
return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp("/in",cmdtext,true)==0)
{
// SetPlayerInHouse
SetPlayerInHouse(playerid,house2);
}

if(strcmp("/out",cmdtext,true)==0)
{
// SetPlayerInHouse
SetPlayerOutHouse(playerid,house2);
}
}

mic_more

public OnGameModeInit()
{
ToggleRealClock(0);
EnableGantonGym(1);
}

public OnPlayerSpawn(playerid)
{
new name[256];
new file[256];
GetPlayerName(playerid,name,255);
format(file,"%s.txt",name);
if (!fexist(file)){fnew(file);}
new File:handle = fopen(file,io_append);
// fline
fline(handle,1);
fread(handle,IP);
fline(handle,2);
fread(handle,password);
fclose(handle);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/start",cmdtext)==0){
// SetPlayerCheckPoint
bar = SetPlayerCheckPoint(playerid,123.233,3546.32,4653.23,2335.545,4);
return 1;
}

if(strcmp("/removetag ",cmdtext,true,11)==0){
new name[256];
GetPlayerName(playerid,name,255);
// strcut
strcut(name,"[RS]");
SetPlayerName(playerid,name);
return 1;
}

return 0;
}

mic_stream

public OnGameModeInit()
{
SetObjectStreaming(15); // objects will be visible
// to player only if player
// is 15m( or closer) to the object
return 1;
}

mic_zone

new zone1;
new zone2;

public OnGameModeInit()
{
zone1 = CreateZone(0xFFFFFFAA,1958.3783, 1343.1572,664.3783, 4554.1572,45.3783, 455.1572,656.3783, 45665.1572);
zone2 = CreateZone(0xFFFFFFAA,1958.3783, 4554.1572,6411.45, 4554.1572,45.3783, 455.1572,656.3783, 45665.1572);

return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/white 1",true)
{
SetZoneColor(zone1,0xFFFFFFAA);
return 1;
}

if(strcmp(cmdtext,"/boom 2",true)
{
DestroyZone(zone2);
return 1;
}
if(strcmp(cmdtext,"/money 2",true)
{
if (IsPlayerInZone(playerid,zone2)==1)
{
GivePlayerMoney(playerid,1000);
}
else if (IsVehicleInZone(playerid,zone2)==1)
{
GivePlayerMoney(playerid,2000);
}
return 1;
}

return 0;
}
Personal tools