PHP код:
CMD:rob(playerid, params[])
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(!strlen(params))
{
SendClientMessage(playerid, RED, "USAGE: /rob [ID]");
}
else
{
ID = strval(params);
if(robtime[playerid] == 0)
{
if(ID != playerid)
{
if(IsPlayerConnected(ID))
{
new oname[MAX_PLAYER_NAME];
GetPlayerName(ID, oname, sizeof(oname));
if(GetDistanceBetweenPlayers(playerid, ID) <= DISTANCE_BETWEEN_PLAYERS)
{
if(!GetPlayerVehicleID(ID) || GetPlayerVehicleID(ID) == GetPlayerVehicleID(ID))
{
if(GetPlayerCash(ID) > 0)
{
new rob = random(11);
if(rob == 1 || rob == 2 || rob == 10 || rob == 11)
{
new string[256];
format(string, sizeof(string), "%s (%i) noticed you trying to rob him. Attempt failed!",oname, ID);
SendClientMessage(playerid, RED, string);
format(string, sizeof(string), "~w~%s Noticed you trying to rob him.~n~Attempt failed!.",oname, ID);
GameTextForPlayer(playerid, string, 5000, 4);
GetPlayerName(playerid,pname,sizeof(pname));
format(string, sizeof(string), "You noticed %s (%i) trying to rob you. His attempt has failed!", pname, playerid);
SendClientMessage(ID, RED, string);
format(string, sizeof(string), "~w~You noticed %s trying to rob you.~n~His attempt has failed!", pname, playerid);
GameTextForPlayer(ID, string, 5000, 4);
}
else if(rob == 3)
{
new pcash = GetPlayerCash(ID);
new robcash = random(pcash);
GivePlayerCash(ID, -robcash);
GivePlayerCash(playerid, robcash);
GetPlayerName(playerid, pname, sizeof(pname));
new string[256];
format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash, oname, ID);
SendClientMessage(playerid, LIGHTGREEN, string);
format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash, oname);
GameTextForPlayer(playerid, string, 5000, 4);
format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash);
SendClientMessage(ID, RED, string);
format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash);
GameTextForPlayer(ID, string, 5000, 4);
}
else if(rob == 4 || rob == 5 || rob == 8)
{
new pcash = GetPlayerCash(ID);
new robcash = random(pcash);
new robcash2 = robcash-random(robcash);
GivePlayerCash(ID, -robcash2);
GivePlayerCash(playerid, robcash2);
new string[256];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash2, oname, ID);
SendClientMessage(playerid, LIGHTGREEN, string);
format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash2, oname);
GameTextForPlayer(playerid, string, 5000, 4);
format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash2);
SendClientMessage(ID, RED, string);
format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash2);
GameTextForPlayer(ID, string, 5000, 4);
}
else if(rob == 6 || rob == 7)
{
new pcash = GetPlayerCash(ID);
new robcash = random(pcash);
new robcash2 = robcash-random(robcash);
new robcash3 = robcash2-random(robcash2);
GivePlayerCash(ID, -robcash3);
GivePlayerCash(playerid, robcash3);
new string[256];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "You have robbed $%i from %s (%i).", robcash3, oname, ID);
SendClientMessage(playerid, LIGHTGREEN, string);
format(string, sizeof(string), "%s (%i) has robbed $%i from you.", pname, playerid, robcash3);
SendClientMessage(ID, RED, string);
format(string, sizeof(string), "~w~Robbed $%i from %s.", robcash3, oname);
GameTextForPlayer(playerid, string, 5000, 4);
format(string, sizeof(string), "~w~%s has robbed $%i from you.", pname, robcash3);
GameTextForPlayer(ID, string, 5000, 4);
}
else
{
SetPlayerHealth(playerid, -69);
new string[256];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "Your hand has stuck to %s (%i)'s pocket. ", oname, ID);
SendClientMessage(playerid, RED, string);
SendClientMessage(playerid, RED, "He noticed it and ripped your arms off.");
format(string, sizeof(string), "%s (%i)'s hand has stuck to your pocket while trying to rob you.", pname, playerid);
SendClientMessage(ID, RED, string);
SendClientMessage(ID, RED, "You noticed it and ripped his arms off.");
format(string, sizeof(string), "*** %s (%i) has bled to death.", pname, playerid);
SendClientMessageToAll(0x880000FF, string);
format(string, sizeof(string), "~w~%s has ripped your arms off.", oname, ID);
GameTextForPlayer(playerid, string, 5000, 4);
format(string, sizeof(string), "~w~Ripped %s's arms off.", oname, ID);
GameTextForPlayer(ID, string, 5000, 4);
}
robtime[playerid] = 0;
SetTimerEx("robtimer", ROB_TIME, false, "i", playerid);
}
else
{
new string[256];
format(string, sizeof(string), "%s (%i) has no money to rob!", oname, ID);
SendClientMessage(playerid, RED, string);
}
}
else
{
new string[256];
format(string, sizeof(string), "%s (%i) has to be in the same vehicle as you to be able to rob!", oname, ID);
SendClientMessage(playerid, RED, string);
}
}
else
{
new string[256];
format(string, sizeof(string), "%s (%i) is not close enough to rob.", oname, ID);
SendClientMessage(playerid, RED, string);
}
}
else
{
SendClientMessage(playerid, RED, "That player is not connected!");
}
}
else
{
SendClientMessage(playerid, RED, "You cannot rob yourself!");
}
}
else
{
SendClientMessage(playerid, RED, "Please wait before robbing someone again.");
}
}
return 1;
}