PDA

View Full Version : [Command Bugged] Each time i use /respawnallcars it says Unknown Command


Rand_Omar
20/03/2010, 04:02 PM
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

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..

Fedee!
20/03/2010, 04:08 PM
[pawn]
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

wafffllesss
20/03/2010, 04:09 PM
Can't find the error but, why are you checking if the player is online? can he make a command offline? :s

Rand_Omar
20/03/2010, 04:13 PM
[pawn]
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..

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.



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


In the gamemode it's based as if he is logged in or not.

Fedee!
20/03/2010, 04:32 PM
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.

Rand_Omar
20/03/2010, 04:39 PM
Same Message

SERVER: Unknown Command :P

MadeMan
20/03/2010, 04:55 PM
for(new car = 1; car <= 268; car++)


Change it to


for(new car = 1; car < CAR_AMOUNT; car++)

Rand_Omar
22/03/2010, 03:03 PM
Still :)

MadeMan
22/03/2010, 03:26 PM
How big is CAR_AMOUNT ?

There should be a line like this somewhere:


#define CAR_AMOUNT

Rand_Omar
22/03/2010, 04:00 PM
lol.. it's 5 :lol:

CSMajor
28/07/2010, 07:27 PM
change the return 1; to return true?

Beljulji
30/09/2012, 12:35 AM
try this one if(strcmp(cmdtext, "/respawncars", true) == 0){
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000AA,"You can't use this command.");
new vh=CreateVehicle(400,0.0,0.0,0.0,0.0,-1,-1,-1);
DestroyVehicle(vh);
new p[MAX_VEHICLES];
for(new v = 0; v < vh; v++){
p[v]=0;
for(new i = 0; i < GetMaxPlayers(); i++){
if(IsPlayerInVehicle(i,v)) p[v]=1;
}
if(p[v]==0) SetVehicleToRespawn(v);
}
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Admin %s Has Respawned all Unused Cars!",pName);
SendClientMessageToAll(lightgreen,string);
return 1;
} rep if helped :D maybe you fixed it but anyway :D