Help with respawn vehicles
#1

Hi,

I'm currently helping a friend with his server and he wanted me to script the /respawncars command
so I this is what I have scripted:

pawn Code:
if(strcmp(cmdtext, "/respawncars", true) == 0)
    {
      if (IsPlayerAdmin(playerid))
      {
         for(new i=0;i<MAX_VEHICLES;i++)
         {
             if(IsVehicleOccupied(i) == 0)
             {
                 SetVehicleToRespawn(i);
            }
         }
            SendClientMessageToAll(COLOR_RED, "All vehicles has been respawned!");
      }
      else
      {
         SendClientMessage(playerid, COLOR_GREY, "You are not RCON Admin");
      }
      return 1;
    }
And I receive the following errors:

Code:
error 017: undefined symbol "IsVehicleOccupied"
I can't seem to fix this command. I've tried so many things and It still gives errors. Can anyone help me with this one ?
Reply
#2

pawn Code:
new inVeh = 0;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        for (new j = 0; j < MAX_PLAYERS; j++)
        {
            if (IsPlayerInVehicle(j, i))
            {
                inVeh = 1;
                break;
            }
        }
       
        if (inVeh != 1)
        {
            SetVehicleToRespawn(i);
        }
        inVeh = 0;
    }
    SendClientMessageToAll(COLOR_RED, "All vehicles has been respawned!");
Reply
#3

Can you tell me where to place that in my script ?
Reply
#4

pawn Code:
if(strcmp(cmdtext, "/respawncars", true) == 0)
    {
        if (IsPlayerAdmin(playerid))
        {
            new inVeh = 0;
            for(new i = 0; i < MAX_VEHICLES; i++)
            {
                for (new j = 0; j < MAX_PLAYERS; j++)
                {
                    if (IsPlayerInVehicle(j, i))
                    {
                        inVeh = 1;
                        break;
                    }
                }
                if (inVeh != 1)
                {
                    SetVehicleToRespawn(i);
                }
                inVeh = 0;
            }
            SendClientMessageToAll(COLOR_RED, "All vehicles has been respawned!");
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You are not RCON Admin");
        }
        return 1;
    }
Reply
#5

Thanks for the help guys. It works now.
This thread can be locked.
Reply
#6

Thanks for the help guys. It works now.
This thread can be locked.
Reply
#7

On second thoughts, this does not respawn the vehicles.
Reply
#8

pawn Code:
if(strcmp(cmdtext, "/respawncars", true) == 0)
    {
        if (IsPlayerAdmin(playerid)){
            new inVeh[MAX_VEHICLES];
            for(new i = 0; i < MAX_VEHICLES; i++){
                for (new j = 0; j < MAX_PLAYERS; j++){
                    if (IsPlayerInVehicle(j, i)){
                        inVeh[i] = GetPlayerVehicleID(j);
                    }
                }
               
                    SetVehicleToRespawn(inVeh[i]);
               
            }
            SendClientMessageToAll(COLOR_RED, "All vehicles has been respawned!");
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You are not RCON Admin");
        }
        return 1;
    }
Please +Rep me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)