[Command Bugged] Each time i use /respawnallcars it says Unknown Command
#1

Hello again, i figured out i am a failure, anyways.. when i found that the command is not working, i took a look at the command in the gamemode, i didn't find anything wrong, and maybe it's like the last bug..


Anyways here is the command
pawn Code:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(PlayerInfo[playerid][pAdmin] < 3)
            {
              SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
              return 1;
            }
            new bool:unwanted[CAR_AMOUNT];
            for(new player=0; player<MAX_PLAYERS; player++)
        {
        if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
        }
            for(new car = 1; car <= 268; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
            BroadCast(COLOR_WHITE,string);
        }
        return 1;
    }
It has no errors, it has nothing wrong.. but it's not working..
Reply
#2

[pawn]
pawn Code:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(PlayerInfo[playerid][pAdmin] < 3)
            {
              SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
              return 1;
            }
            else
            new bool:unwanted[CAR_AMOUNT];
            for(new player=0; player<MAX_PLAYERS; player++)
        {
        if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
        }
            for(new car = 1; car <= 268; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
            BroadCast(COLOR_WHITE,string);
        }
        return 1;
    }
Try that
Reply
#3

Can't find the error but, why are you checking if the player is online? can he make a command offline?
Reply
#4

Quote:
Originally Posted by Fedee!
[pawn]
pawn Code:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
        if(PlayerInfo[playerid][pAdmin] < 3)
            {
              SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
              return 1;
            }
            else
            new bool:unwanted[CAR_AMOUNT];
            for(new player=0; player<MAX_PLAYERS; player++)
        {
        if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
        }
            for(new car = 1; car <= 268; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
            BroadCast(COLOR_WHITE,string);
        }
        return 1;
    }
Try that
I tried that, and..
pawn Code:
C:\Users\*\Desktop\Universal RP\Universal RP\gamemodes\*.pwn(12866) : error 003: declaration of a local variable must appear in a compound block
C:\Users\*\Desktop\Universal RP\Universal RP\gamemodes\*.pwn(12866) : warning 221: label name "bool" shadows tag name
C:\Users\*\Desktop\Universal RP\Universal RP\gamemodes\*.pwn(12866) : error 017: undefined symbol "unwanted"
C:\Users\*\Desktop\Universal RP\Universal RP\gamemodes\*.pwn(12866) : warning 215: expression has no effect
C:\Users\*\Desktop\Universal RP\Universal RP\gamemodes\*.pwn(12866) : error 001: expected token: ";", but found "]"
C:\Users\*\Desktop\Universal RP\Universal RP\gamemodes\*.pwn(12866) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
NOTE: I didn't look at the errors to fix them.


Quote:
Originally Posted by wafffllesss
Can't find the error but, why are you checking if the player is online? can he make a command offline?
In the gamemode it's based as if he is logged in or not.
Reply
#5

pawn Code:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0)
  {
    if(PlayerInfo[playerid][pAdmin] < 3)
    {
      SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
        return 1;
    }
    else
        {
          new bool:unwanted[CAR_AMOUNT];
      for(new player=0; player<MAX_PLAYERS; player++)
          {
        if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
        }
            for(new car = 1; car <= 268; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
            BroadCast(COLOR_WHITE,string);
        }
  }
And, IsPlayerConnected is not for checking if he is logged.
Reply
#6

Same Message

SERVER: Unknown Command :P
Reply
#7

pawn Code:
for(new car = 1; car <= 268; car++)
Change it to

pawn Code:
for(new car = 1; car < CAR_AMOUNT; car++)
Reply
#8

Still
Reply
#9

How big is CAR_AMOUNT ?

There should be a line like this somewhere:

pawn Code:
#define CAR_AMOUNT
Reply
#10

lol.. it's 5
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)