Please help me finish my /destroyallvehicles command -
Markhoss - 22.11.2018
Hello everyone and thanks for reading this.
Basically what I want to achieve is if the player is an admin and is logged in the rcon I want to make a command where he can delete all the spawned vehicles and this is what I made in PAWN so far:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
if(!strcmp("/destroyallvehicles", cmdtext, == 0)
//if(!strcmp("/destroyallvehicles", cmdtext, == 0) //true)) //true, 8)) //true, == 0)
{
if(IsPlayerAdmin(playerid))
//if(PlayerInfo[playerid][pAdmin] >=
new vehid= GetPlayerVehicleID(playerid);
while(IsVehicleConnected(++vehid)) DestroyVehicle(vehid);
new spawnedcar = vehid >=400; vehid < 611; vehid++)
return 1;
}
return 0;
}
Right of the bat I know I should be using a different CMD system by now but I just haven't learned it yet so please excuse me.
These are the errors I get:
C:\Users\Markhoss\Desktop\SAMP Prison Malmedes Server\gamemodes\prisonmalmedes.pwn(1139) : error 029: invalid expression, assumed zero
C:\Users\Markhoss\Desktop\SAMP Prison Malmedes Server\gamemodes\prisonmalmedes.pwn(1139) : warning 215: expression has no effect
C:\Users\Markhoss\Desktop\SAMP Prison Malmedes Server\gamemodes\prisonmalmedes.pwn(1139) : error 001: expected token: ";", but found ")"
C:\Users\Markhoss\Desktop\SAMP Prison Malmedes Server\gamemodes\prisonmalmedes.pwn(1139) : error 029: invalid expression, assumed zero
C:\Users\Markhoss\Desktop\SAMP Prison Malmedes Server\gamemodes\prisonmalmedes.pwn(1139) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Which is on the public OnPlayerCommandText(playerid, cmdtext[]) line.
I suppose the next lines also cause errors but I can't know that until I fix the first line so thanks so much in advance for any advice!
Re: Please help me finish my /destroyallvehicles command -
OKStyle - 22.11.2018
if(IsPlayerAdmin(playerid)) -> if(!IsPlayerAdmin(playerid)) return 1;
Re: Please help me finish my /destroyallvehicles command -
Markhoss - 22.11.2018
Quote:
Originally Posted by OKStyle
if(IsPlayerAdmin(playerid)) -> if(!IsPlayerAdmin(playerid)) return 1;
|
Thanks I've added that in.
Re: Please help me finish my /destroyallvehicles command -
Markhoss - 22.11.2018
However I need to fix the first line somehow.
Re: Please help me finish my /destroyallvehicles command -
SiNaGaMeR - 22.11.2018
PHP код:
if(strcmp(cmd, "/destroyallvehs", true) == 0)
Re: Please help me finish my /destroyallvehicles command -
OKStyle - 22.11.2018
Function has no params cuz cmd not valid btw.
I did not fully understand what the team should do in the end, but I would have written so for a start:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/destroyallvehicles"))
{
if(IsPlayerAdmin(playerid)) return 1;
for(new i = GetVehiclePoolSize(); i > 0; i--) if(GetVehicleModel(i)) DestroyVehicle(i);
return 1;
}
return 0;
}
Re: Please help me finish my /destroyallvehicles command -
v1k1nG - 22.11.2018
May I suggest you to use another command processor?
Most famous are zcmd and ycmd, you can find their threads in the forums.
Here is an example with zmcd
PHP код:
CMD:destroyallvehicles(playerid, params[])
{
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdmin] < 5){
return SendClientMessage(playerid, -1, "You need to be RCON Admin or Level 5 Administrator to do that");
}
for(new i, j = MAX_VEHICLES; i != j; i++){
if(IsValidVehicle(i)){
DestroyVehicle(i);
}
}
SendClientMessage(playerid, -1, "Vehicles Destroyed");
return 1;
}
;