15.05.2010, 17:37
Hello, My kidnap command is having issues, It says "Player must be a passenger" When they already are.
Can't seem to see the problem, please help.
pawn Код:
if(strcmp(cmd, "/kidnap", true) == 0)
{
if(IsSpawned[playerid] == 0) {
SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command.");
return 1;
}
if(gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_ARMY ||
gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_CASSEC ||
gTeam[playerid] == TEAM_JAILTK || gTeam[playerid] == TEAM_DRIVER ||
gTeam[playerid] == TEAM_MARINE || gTeam[playerid] == TEAM_AIRSUPPORT) {
SendClientMessage(playerid,COLOR_ERROR,"Law enforcment officers cannnot kidnap players");
return 1;
}
if(gTeam[playerid] != TEAM_KIDNAPPER) {
SendClientMessage(playerid, COLOR_ERROR, "Only Kidnappers can use this command");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /kidnap (id)");
return 1;
}
if(cuffed[playerid] == 1) {
SendClientMessage(playerid,COLOR_ERROR,"You are handcuffed. You cannot use this command");
return 1;
}
if(isKidnapped[playerid] == 1) {
SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped yourself, pay the kidnapper with /ransom.");
return 1;
}
if(Jailed[playerid] == 1) {
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command in jail");
return 1;
}
if(!IsNumeric(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /kidnap (id) ID Must be a number");
return 1;
}
if(strval(tmp) == playerid) {
SendClientMessage(playerid, COLOR_ERROR, "You cannot kidnap yourself");
return 1;
}
if(GetPlayerState(giveplayerid) != PLAYER_STATE_PASSENGER) {
SendClientMessage(playerid,COLOR_ERROR,"The player must be a passanger");
return 1;
}
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) {
SendClientMessage(playerid, COLOR_ERROR, "You are not the driver of this vehicle. Only the driver can kidnap players");
return 1;
}
if(cuffed[giveplayerid] == 1) {
SendClientMessage(playerid,COLOR_ERROR,"This player is cuffed, you cannot kidnap him");
return 1;
}
new kidnappername[24];
new victimname[24];
GetPlayerName(playerid,kidnappername, 24);
GetPlayerName(giveplayerid, victimname, 24);
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3) {
format(szstring, sizeof(szstring), "%s(%d) Is not close enough. You cannot kidnap that player",victimname,giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
if(GetPlayerState(giveplayerid) == PLAYER_STATE_PASSENGER) {
format(szstring, sizeof(szstring), "You have kidnapped %s(%d).",victimname,giveplayerid);
SendClientMessage(playerid,COLOR_ROYALBLUE,szstring);
SendClientMessage(giveplayerid,COLOR_ERROR,"You have been kidnapped!");
format(szstring, sizeof(szstring), "(Kidnapping) %s(%d) Has been kidnapped by $%d",kidnappername,playerid,victimname,giveplayerid);
SendClientMessageToAll(0x00C7FFAA,szstring);
TogglePlayerControllable(giveplayerid, 0);
isKidnapped[giveplayerid] = 1;
kidnapTimer[giveplayerid] = 180;
new pcol = GetPlayerColor(playerid);
new plwl = GetPlayerWantedLevel(playerid);
plwl = GetPlayerWantedLevel(playerid);
commitedcrimerecently[playerid] +=120;
SetPlayerWantedLevel(playerid, plwl +4);
SendClientMessage(playerid, 0xA9A9A9AA, "|_Crime Commited_|");
format(szstring, sizeof(szstring), "(KIDNAPPING) Wanted Level %d",plwl);
SendClientMessage(playerid,pcol,szstring);
oscore = GetPlayerScore(playerid);
SetPlayerScore(playerid, oscore +1);
for(new i=0;i<MAX_PLAYERS;i++) {
if(LawEnforcementRadio[i] == 1) {
new szstring1[256];
new szstring2[256];
new current_zone;
current_zone = player_zone[playerid];
format(szstring1, sizeof(szstring1), "DISPATCH: (KIDNAPPING) Suspect: %s(%d) Victim:",kidnappername,playerid,victimname,giveplayerid);
format(szstring2, sizeof(szstring2), "ALL UNITS: Please respond to %s and arrest %s(%d)",zones[current_zone][zone_name],kidnappername,giveplayerid);
SendClientMessage(i, COLOR_ROYALBLUE, szstring1);
SendClientMessage(i, COLOR_ROYALBLUE, szstring2);
}
}
}
return 1;
}