03.04.2012, 22:31
So here is a /rape code I'm testing out for another server:
Apparently, if you're ID 0 when you join the game, you cannot rape other players. When you type /rape , it says Usage: /rape (ID). If you are still ID 0 and you type in /rape 1 , (id 1), it says You cannot rape yourself.. But if you're ID 1 or above ID 0 when you join the game, and you type in /rape 0 or /rape 1 , it works. Why does this happen? Can anybody find out what's wrong with the code? REP+!
Код:
command(rape, playerid, params[]) { new pname[24]; new opname[24]; new ID; GetPlayerName(playerid, pname, 24); new string[200]; if(gTeam[playerid] == Team_Cop || gTeam[playerid] == Team_Army || gTeam[playerid] == Team_FBI) { return SendClientMessage(playerid, COLOR_ERROR, "Cops/Army cannot rape people."); } if(gTeam[playerid] == Team_Terror || gTeam[playerid] == Team_Rape || gTeam[playerid] == Team_PrvtMed || gTeam[playerid] == Team_Steal) { if(GetPVarInt(playerid, "RapeRecently") == 1) { return SendClientMessage(playerid, COLOR_ERROR, "Command used recently. Please wait."); } if(GetPVarInt(playerid, "Spawned") == 0) { return SendClientMessage(playerid, COLOR_ERROR, "You must be alive to use that command."); } if(GetPVarInt(playerid, "Cuffed") == 1) { return SendClientMessage(playerid, COLOR_ERROR, "You are cuffed. You cannot use this command."); } if(GetPVarInt(playerid, "Jailed") == 1) { return SendClientMessage(playerid, COLOR_ERROR, "You are in jail. You cannot use this command."); } if(IsPlayerInAnyVehicle(playerid)) { return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while in a vehicle."); } if(sscanf(params, "u", ID)) { return SendClientMessage(playerid, COLOR_RED, "Usage: /rape (ID)"); } GetPlayerName(ID, opname, 24); if(ID == playerid) { return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape yourself."); } if(!IsPlayerConnected(ID)) { return SendClientMessage(playerid, COLOR_ERROR, "Invalid Player ID."); } if(GetPVarInt(ID, "Jailed") == 1) { return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape a prisoner."); } if(GetPVarInt(ID, "Cuffed") == 1) { return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape that player. He/She is cuffed."); } if(IsPlayerInAnyVehicle(ID)) { return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape a player in a vehicle."); } if(GetDistanceBetweenPlayers(playerid, ID) > 4) { return SendClientMessage(playerid, COLOR_ERROR, "Your dick is not big enough! Get closer!"); } if(GetPVarInt(ID, "HasCondom") == 1) { SendClientMessage(playerid, COLOR_ERROR, "That player had a condom. You failed to rape them."); SendClientMessage(ID, COLOR_ERROR, "Your condom has protected you from a rape. You have lost your condom."); SetPVarInt(ID, "HasCondom", 0); } format(string, sizeof(string), "**RAPE COMPLETE**"); SendClientMessage(playerid, COLOR_GREY, string); format(string, sizeof(string), "You have raped %s(%d).", opname, ID); SendClientMessage(playerid, COLOR_GREEN, string); if(gTeam[playerid] == Team_Rape) { format(string, sizeof(string), "%s(%d) has been infected with STDs.", opname, ID); SendClientMessageToAll(COLOR_RED, string); IRC_Say(gGroupID, IRC_CHANNEL, string); SetPVarInt(ID, "HasSTDs", 1); } if(gTeam[ID] == Team_Cop || gTeam[ID] == Team_FBI || gTeam[ID] == Team_Army) { IncreaseWantedLevel(playerid, 2); } if(gTeam[ID] == Team_Rape || gTeam[ID] == Team_Terror || gTeam[ID] == Team_Steal || gTeam[ID] == Team_PrvtMed) { IncreaseWantedLevel(playerid, 1); } new current_zone = player_zone[playerid]; //zones[current_zone][zone_name] format(string, sizeof(string), "**RAPE VICTIM**"); SendClientMessage(ID, COLOR_GREY, string); format(string, sizeof(string), "You have been raped by %s(%d). You might have STDs.", pname, playerid); SendClientMessage(ID, COLOR_GREEN, string); format(string, sizeof(string), "%s(%d) has raped %s(%d)", pname, playerid, opname, ID); SendClientMessageToAll(COLOR_LIGHTBLUE, string); IRC_Say(gGroupID, IRC_CHANNEL, string); SetPVarInt(playerid, "RapeRecently", 1); SetTimer("RapeAgain", 1000*6*2, 0); format(string, 120, "[DISPATCH] %s(%d) has raped %s(%d) Location: %s", pname, playerid, opname, ID, zones[current_zone][zone_name]); SendCopMessage(string); return 1; } return 1; }