plzz help in /arrest
#1

when im doing /arrest it asks me player ID i want to make it without asking playerID so please help me how can i make this command that it wont ask me player id it just arrest nearest players without askin playerID here is the my gamemode command line



if(strcmp(cmd, "/arrest", true) == 0 || strcmp(cmd, "/ar", true) == 0)
{
new string[250];
if(IsSpawned[playerid] == 0)
{
SendClientMessage(playerid, COLOR_ERROR, "You Are Dead! You Cannot use This Command");
return 1;
}
if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
{
SendClientMessage(playerid,COLOR_ERROR,"The Task Does Not Allowed For You Due To Your Current Skill");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ar (id)");
return 1;
}
giveplayerid = strval(tmp);
if(!IsNumeric(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ar (id) ID Must Be A Number");
return 1;
}
if(!IsPlayerConnected(giveplayerid))
{
format(string, sizeof(string), "ID (%d) is Not An Active Player.", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
new oname[24];
new pname[24];
GetPlayerName(playerid,oname, 24);
GetPlayerName(giveplayerid, pname, 24);
if(GetPlayerWantedLevel(giveplayerid) <= 3)
{
format(string, sizeof(string), "%s(%d) Does Not Have A Warrant! You Cannot Arrest A Player Without A Warrant",pname,giveplayerid);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Arrest A Suspect if You Are in A Car");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,giveplayerid ) > 10)
{
format(string, sizeof(string), "%s(%d) is Too Far Away! You Cannot Arrest That Player.",pname,giveplayerid);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(IsSpawned[giveplayerid] == 0)
{
format(string, sizeof(string), "%s(%d) is Dead! You Cannot Arrest A Dead Body.",pname,giveplayerid);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
SetPlayerVirtualWorld(giveplayerid,0);
if(GetPlayerWantedLevel(playerid) >=1)
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot use This Command if You Are Wanted By The Police.");
return 1;
}
if(giveplayerid == playerid)
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Arrest Yourself.");
return 1;
}
new spawn = random(sizeof(PrisonSpawn)), string2[250], Float:health, copname[MAX_PLAYER_NAME], arrested[MAX_PLAYER_NAME];
GetPlayerName(playerid, copname, sizeof(copname));
GetPlayerName(strval(tmp), arrested, sizeof(arrested));
GetPlayerHealth(strval(tmp), health);
SendClientMessage(strval(tmp), GREY, "|_ San Andreas Police Dept _|");
format(string, sizeof(string), "{00CCFF}Officer {00CC66}%s {FFFFFF}Has Arrested You.", copname);
SendClientMessage(strval(tmp), WHITE, string);
ResetPlayerWeapons(strval(tmp));
SetPlayerPos(strval(tmp), PrisonSpawn[spawn][0], PrisonSpawn[spawn][1], PrisonSpawn[spawn][2]);
SetPlayerFacingAngle(strval(tmp), PrisonSpawn[spawn][3]);
SetCameraBehindPlayer(strval(tmp));
if(GetPlayerWantedLevel(strval(tmp)) >= 4 && GetPlayerWantedLevel(strval(tmp)) <= 5)
{
PrisonTime[strval(tmp)] = 20;
GivePlayerMoney(playerid,25000);
GivePlayerScore(playerid,2);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 6 && GetPlayerWantedLevel(strval(tmp)) <=
{
PrisonTime[strval(tmp)] = 25;
GivePlayerMoney(playerid,5000);
GivePlayerScore(playerid,1);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 9 && GetPlayerWantedLevel(playerid) <= 11)
{
PrisonTime[strval(tmp)] = 30;
GivePlayerMoney(playerid,6000);
GivePlayerScore(playerid,1);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 12 && GetPlayerWantedLevel(strval(tmp)) <= 14)
{
PrisonTime[strval(tmp)] = 35;
GivePlayerMoney(playerid,7000);
GivePlayerScore(playerid,1);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 15)
{
PrisonTime[strval(tmp)] = 40;
GivePlayerMoney(playerid,8000);
GivePlayerScore(playerid,1);
}
SetPlayerWantedLevel(strval(tmp), 0);
SetPlayerInterior(strval(tmp),3);
SetPlayerHealth(strval(tmp),99999);
TogglePlayerControllable(strval(tmp), true);
SetPlayerJailed(strval(tmp), true);
format(string2, sizeof(string2), "{00CCFF}Officer {33CC33}- %s(%d) {FFFFFF}Has {6699FF}Arrested {FFFFFF}Suspect {33CC33}%s(%d)", copname, playerid, arrested, strval(tmp));
Announce(string2);
if(health <= 90)
{
SendClientMessage(strval(tmp), GREY, "|_ San Andreas Police Dept _|");
SendClientMessage(strval(tmp), WHITE, "SAPD Has Given You Some Food.");
SetPlayerHealth(strval(tmp), health+10);
ApplyAnimation(strval(tmp), "FOOD", "EAT_Burger", 4.0, 0, 0, 0, 0, 0);
}
return 1;
}
Reply
#2

no one..?
Reply
#3

First of all, use ZCMD, not strtok.
And to change the command, use foreach with IsPlayerInRangeOfPoint and that's it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)