28.07.2009, 08:51
Oh my bad, I see where I went wrong now.
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
new giveplayername[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME];
new string[128];
if(strcmp("/rob", cmdtext, true, 10) == 0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone while being in a Car!");
return 1;
}
new victim = GetClosestPlayer(playerid);
if(IsPlayerConnected(victim))
{
if(GetDistanceBetweenPlayers(playerid,victim) < 5)
{
if(IsPlayerInAnyVehicle(victim))
{
SendClientMessage(playerid, COLOR_GREY, "You cannot rob someone who is in a car!");
return 1;
}
GetPlayerName(victim, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
new randt = random(4)+1;
if(randt == 1)
{
format(string, sizeof(string), "* %s shoots with his Tazer at %s, but missed.", sendername ,giveplayername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else
{
format(string, sizeof(string), "* You were robbed by %s.", sendername);
SendClientMessage(victim, COLOR_WHITE, string);
format(string, sizeof(string), "* You robbed %s and stole $$s.", giveplayername, GetPlayerMoney(victim));
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s puts his hand into %s 's pocket and steals his money.", sendername ,giveplayername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(victim, "~r~Robbed", 2500, 3);
GivePlayerMoney(playerid, GetPlayerMoney(victim));
ResetPlayerMoney(victim);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " No-one near you!");
return 1;
}
}
}
return 1;
}
return 0;
}