01.06.2010, 02:09
I have a /drag command that works pretty well ( i know it can be abused, because i havint added many things lol, i'm still on process of making it)
The problem is, How can I display something like "You need to have a car before you /drag a suspect" If a player has not previously entered a car?
The problem is, How can I display something like "You need to have a car before you /drag a suspect" If a player has not previously entered a car?
pawn Код:
if(strcmp(cmd, "/drag", true) == 0)
{
if(IsSpawned[playerid] == 0) {
SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
return 1;
}
if(Jailed[playerid] ==1) {
SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command in jail");
return 1;
}
if(gTeam[playerid] != TEAM_COP) {
SendClientMessage(playerid,COLOR_ERROR,"You are not part of the SWAT team. Only SWAT can use this command");
return 1;
}
if(InDerby[playerid] == 1) {
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command while you are in the stadium");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /drag (id)");
return 1;
}
giveplayerid = strval(tmp);
if(!IsPlayerConnected(giveplayerid)) {
format(szstring, sizeof(szstring), "ID (%d) is not an active player", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
GetPlayerName(playerid,oname, 24);
GetPlayerName(giveplayerid, pname, 24);
if(!IsNumeric(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /drag (id) ID Must be a number");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 4) {
format(szstring, sizeof(szstring), "%s(%d) Is not close enough you cannot drag that player",pname, giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
if(Jailed[giveplayerid] == 1) {
format(szstring, sizeof(szstring), "%s(%d) Is in jail. You cannot drag a prisoner",pname, giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
if(IsPlayerInAnyVehicle(playerid)) {
SendClientMessage(playerid, COLOR_ERROR, "You are in a vehicle. You must be on foot to drag");
return 1;
}
if(IsPlayerInAnyVehicle(giveplayerid)) {
SendClientMessage(playerid, COLOR_ERROR, "That player is already in a vehicle");
return 1;
}
SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_DRAGGED_|");
format(szstring, sizeof(szstring), "%s(%d): has dragged you,use /breakcuffs to attempt an escape!",oname, playerid);
SendClientMessage(giveplayerid, COLOR_DODGERBLUE, szstring);
TogglePlayerControllable(giveplayerid, 0);
isKidnapped[giveplayerid] =1;
oscore = GetPlayerScore(playerid);
SetPlayerScore(playerid, oscore +1);
SendClientMessage(playerid, 0xA9A9A9AA, "|_Criminal Dragged|");
format(szstring, sizeof(szstring), "You have grabbed %s(%d) and thrown him into your car!", pname, giveplayerid);
SendClientMessage(playerid, COLOR_DODGERBLUE, szstring);
format(szstring, sizeof(szstring), "%s(%d) has grabbed %s(%d) and thrown him into his car!",oname,playerid,pname,giveplayerid);
SendClientMessageToAll(0x00C7FFAA, szstring);
PutPlayerInVehicle(giveplayerid,KidCar[playerid],1);
HasKidnapped[playerid] =1;
format(szstring, sizeof(szstring), "~r~DRAGGED BY SWAT MEMBER~n~~w~%s(%d)",oname,playerid);
GameTextForPlayer(giveplayerid,szstring,5000,3);
return 1;
}
pawn Код:
new KidCar[MAX_PLAYERS];
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && gTeam[playerid] == TEAM_KIDNAPPER)
{
KidCar[playerid] = GetPlayerVehicleID(playerid);
}