Respawn All Cars
#1

Okay, I made a code to respawn all cars by myself. Except, It make errors!

CODE:
pawn Код:
if(strcmp(cmd, "/resallcar", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 5)
{
for(new i = 0; i <= MAX_PLAYERS; i++)
new carid = GetPlayerVehicleID(i);
if(!IsVehicleOccupied(carid))
{
SetVehicleToRespawn(carid);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "AdmCmd: %s has respawned all unoccupied vehicles!", sendername);
SendClientMessageToAll(COLOR_ADMIN, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not authorised to use this command!");
}
return 1;
}
}


ERRORS:

Код:
C:\Users\Lachlan\Desktop\Hosting Server\pawno\SW-RP.pwn(8885) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Lachlan\Desktop\Hosting Server\pawno\SW-RP.pwn(8885) : error 017: undefined symbol "carid"
C:\Users\Lachlan\Desktop\Hosting Server\pawno\SW-RP.pwn(8885) : error 017: undefined symbol "i"
C:\Users\Lachlan\Desktop\Hosting Server\pawno\SW-RP.pwn(8885) : fatal error 107: too many error messages on one line
Reply
#2

pawn Код:
...
new carid = GetPlayerVehicleID(i);
if(!IsVehicleOccupied(carid))
...
Are you kidding me?
Reply
#3

pawn Код:
for(new pl = 0; pl<MAX_PLAYERS; pl++)
    {
        if(IsPlayerConnected(pl))
        {
            if(!IsPlayerInVehicle(pl, i))
            {
                SetVehicleToRespawn(i);
            }
        }
    }
Reply
#4

Quote:
Originally Posted by //exora
pawn Код:
for(new pl = 0; pl<MAX_PLAYERS; pl++)
    {
        if(IsPlayerConnected(pl))
        {
            if(!IsPlayerInVehicle(pl, i))
            {
                SetVehicleToRespawn(i);
            }
        }
    }
When did people become vehicles?
Reply
#5

pawn Код:
if(strcmp(cmdtext, "/resallcar", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_RED, "You are not authorised to use this command!");
    for(new cars=0; cars<MAX_VEHICLES; cars++)
    {
        if(!IsVehicleOccupied(cars))//if cars is not occupied.
        {
            SetVehicleToRespawn(cars);
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "AdmCmd: %s has respawned all unoccupied vehicles!", sendername);
            SendClientMessageToAll(COLOR_ADMIN, string);
        }
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by Joe Staff
When did people become vehicles?
Fail, I forgot the vehicle loop, lol.
Reply
#7

Dunnojo's works, but It sends 10,000 Messages that cars were respawed
Reply
#8

Oh yeah, sorry.
pawn Код:
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "AdmCmd: %s has respawned all unoccupied vehicles!", sendername);
SendClientMessageToAll(COLOR_ADMIN, string);
Move that right over the return 1; and below the brace }
Reply
#9

So....

pawn Код:
if(strcmp(cmdtext, "/resallcar", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_RED, "You are not authorised to use this command!");
for(new cars=0; cars<MAX_VEHICLES; cars++)
{
if(!IsVehicleOccupied(cars))//if cars is not occupied.
{
SetVehicleToRespawn(cars);
}
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "AdmCmd: %s has respawned all unoccupied vehicles!", sendername);
SendClientMessageToAll(COLOR_ADMIN, string);
return 1;
}
??
Reply
#10

Yep, just like that.
Or like this, if you think that looks better.
pawn Код:
if(strcmp(cmdtext, "/resallcar", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_RED, "You are not authorised to use this command!");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "AdmCmd: %s has respawned all unoccupied vehicles!", sendername);
    SendClientMessageToAll(COLOR_ADMIN, string);
    for(new cars=0; cars<MAX_VEHICLES; cars++)
    {
        if(!IsVehicleOccupied(cars))//if cars is not occupied.
        {
            SetVehicleToRespawn(cars);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)