06.08.2013, 00:31
hey i scriped this little rob (id) command but i am having a prolem were i i rob other people but it wont give the the a guy who robbed the money yes everything work as the player dont have cash , and all that, but when player have cash and the robber try to rob the player it will rob the player but the robber wont get money , and the player who got robbed wont lose the ammount of money the robber robbed here is my code can anyone see whats wrong thank you,
PHP код:
cmd(rob, playerid, params[])
{
new ID; new string[120];
if(gTeam[playerid] != Team_Steal && gTeam[playerid] != Team_Terror && gTeam[playerid] != Team_Rape && gTeam[playerid] != Team_Civi && gTeam[playerid] != TEAM_HITMAN)
return SendClientMessage(playerid, COLOR_RED, "You Must be a Civil to use this command.");
if(GetPVarInt(ID, "HasSecureWallet") == 1)
{
SendClientMessage(playerid, COLOR_RED, "That player had a SecureWallet. You failed to rob them.");
SendClientMessage(ID, COLOR_RED, "Your SecureWallet has protected you from a A robbery. You Have lost lost a Securewallet");
return 1;
}
if(GetPVarInt(playerid, "Jailed") == 1)
return SendClientMessage(playerid, COLOR_RED, "You cannot use this command in jail.");
if(GetPVarInt(playerid, "Cuffed") == 1)
return SendClientMessage(playerid, COLOR_RED, "You cannot use this command while cuffed.");
if(sscanf(params, "u", ID))
return SendClientMessage(playerid, COLOR_ERROR, "Usage: /rob (ID)");
if(!IsPlayerConnected(ID))
return SendClientMessage(playerid, COLOR_RED, "Invalid Player ID.");
if(GetPlayerMoney(ID) <=0)
return SendClientMessage(playerid, COLOR_RED, "That player doesn't have any money.");
if(GetDistanceBetweenPlayers(playerid, ID) > 5)
return SendClientMessage(playerid, COLOR_RED, "That player is too far away.");
if(IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_RED, "You cannot use this command while in a vehicle.");
if(IsPlayerInAnyVehicle(ID))
return SendClientMessage(playerid, COLOR_RED, "You cannot rob them when they are in a vehicle.");
if(GetPVarInt(playerid, "RobbedPlayerRecent") >= 1)
return SendClientMessage(playerid, COLOR_RED, "You must wait before robbing a player again.");
new chance = random(10);
if(chance == 1)
return SendClientMessage(playerid, COLOR_RED, "You failed the robbery.");
new mrand = random(GetPlayerMoney(ID));
new current_zone = player_zone[playerid];
if(IsCop(ID))
{
format(string, 120, "[ROBBED] %s has robbed $%d from you!", PlayerInfo(playerid), mrand);
SendClientMessage(ID, COLOR_RED, string);
format(string, 120, "[ROBBERY] You robbed $%d from %s!", mrand, PlayerInfo(ID));
SendClientMessage(playerid, COLOR_RED, string);
GivePlayerMoney(playerid,mrand);
format(string, 120, "[ROBBERY] %s robbed $%d from %s!", PlayerInfo(playerid), mrand, PlayerInfo(ID));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
CNR_PrintString(string);
format(string, 120, "[DISPATCH] %s has been robbed by %s. Location: %s", PlayerInfo(ID), PlayerInfo(playerid), playerid,zones[current_zone][zone_name]);
SendCopMessage(string);
format(string, 120, "Type /radioof to turn off the Police Radio.");
SendCopMessage(string);
IncreaseWantedLevel(playerid, 2);
IncreaseScore(playerid, 2);
if(GetPVarInt(playerid, "RobSkill") <= 3)
{
SetPVarInt(playerid, "RobSkill", GetPVarInt(playerid, "RobSkill") +1);
format(string, 120, "[SKILL UPGRADE] Your robbing skill has increased. Read /robjob.");
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}
if(AttemptedToRobRecently[playerid] >= 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You are too tired from your last rob attempt. Please wait before robbing again.");
return 1;
}
if(HasRobbedRecently[playerid] >= 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You are too tired from the last person you robbed. Please wait before robbing again.");
return 1;
}
if(GetPlayerMoney(ID) <= 0)
{
SendClientMessage(playerid,COLOR_ERROR,"That player has no money in their pockets. What would be the point in robbing them?");
return 1;
}
format(string, 120, "[ROBBED] %s has robbed $%d from you!", PlayerInfo(playerid), mrand);
SendClientMessage(ID, COLOR_RED, string);
format(string, 120, "[ROBBERY] You robbed $%d from %s!", mrand, PlayerInfo(ID));
SendClientMessage(playerid, COLOR_RED, string);
format(string, 120, "[ROBBERY] %s robbed $%d from %s!", PlayerInfo(playerid), mrand, PlayerInfo(ID));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
CNR_PrintString(string);
format(string, 120, "[DISPATCH] %s has been robbed by %s. Location: %s", PlayerInfo(ID), PlayerInfo(playerid), playerid,zones[current_zone][zone_name]);
SendCopMessage(string);
format(string, 120, "Type /radioof to turn off the Police Radio.");
SendCopMessage(string);
IncreaseWantedLevel(playerid, 1);
IncreaseScore(playerid, 1);
if(GetPVarInt(playerid, "RobSkill") <= 3)
{
SetPVarInt(playerid, "RobSkill", GetPVarInt(playerid, "RobSkill") +1);
format(string, 120, "[SKILL UPGRADE] Your robbing skill has increased. Read /robjob.");
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}