Please help me finish my /destroyallvehicles command
#1

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!
Reply
#2

if(IsPlayerAdmin(playerid)) -> if(!IsPlayerAdmin(playerid)) return 1;
Reply
#3

Quote:
Originally Posted by OKStyle
Посмотреть сообщение
if(IsPlayerAdmin(playerid)) -> if(!IsPlayerAdmin(playerid)) return 1;
Thanks I've added that in.
Reply
#4

However I need to fix the first line somehow.
Reply
#5

PHP код:
if(strcmp(cmd"/destroyallvehs"true) == 0
Reply
#6

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;
}
Reply
#7

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(playeridparams[])
{
    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 
iMAX_VEHICLES!= ji++){
        if(
IsValidVehicle(i)){
            
DestroyVehicle(i);
        }
    }
    
SendClientMessage(playerid, -1"Vehicles Destroyed");
    return 
1;

;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)