SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/02/2012, 06:33 PM   #1
sniperwars
Huge Clucker
 
Join Date: Jan 2011
Location: Under your bed.
Posts: 443
Reputation: 22
Default Help with respawn vehicles

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 ?
__________________
sniperwars is online now   Reply With Quote
Old 24/02/2012, 06:42 PM   #2
dice7
High-roller
 
Join Date: Apr 2009
Location: Slovenia
Posts: 2,200
Reputation: 22
Default Re: Help with respawn vehicles

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!");
dice7 is offline   Reply With Quote
Old 24/02/2012, 07:11 PM   #3
sniperwars
Huge Clucker
 
Join Date: Jan 2011
Location: Under your bed.
Posts: 443
Reputation: 22
Default Re: Help with respawn vehicles

Can you tell me where to place that in my script ?
__________________
sniperwars is online now   Reply With Quote
Old 24/02/2012, 07:17 PM   #4
dice7
High-roller
 
Join Date: Apr 2009
Location: Slovenia
Posts: 2,200
Reputation: 22
Default Re: Help with respawn vehicles

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;
    }
dice7 is offline   Reply With Quote
Old 24/02/2012, 08:50 PM   #5
sniperwars
Huge Clucker
 
Join Date: Jan 2011
Location: Under your bed.
Posts: 443
Reputation: 22
Default Re: Help with respawn vehicles

Thanks for the help guys. It works now.
This thread can be locked.
__________________
sniperwars is online now   Reply With Quote
Old 24/02/2012, 08:53 PM   #6
sniperwars
Huge Clucker
 
Join Date: Jan 2011
Location: Under your bed.
Posts: 443
Reputation: 22
Default Re: Help with respawn vehicles

Thanks for the help guys. It works now.
This thread can be locked.
__________________
sniperwars is online now   Reply With Quote
Old 24/02/2012, 09:26 PM   #7
sniperwars
Huge Clucker
 
Join Date: Jan 2011
Location: Under your bed.
Posts: 443
Reputation: 22
Default Re: Help with respawn vehicles

On second thoughts, this does not respawn the vehicles.
__________________
sniperwars is online now   Reply With Quote
Old 24/02/2012, 11:51 PM   #8
Marco_Valentine
Huge Clucker
 
Join Date: Apr 2011
Location: South, Australia
Posts: 211
Reputation: 29
Default Re: Help with respawn vehicles

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
Marco_Valentine is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Respawn vehicles.. DevilRP Scripting Help 10 10/03/2012 01:39 PM
Respawn Vehicles? Xx_OutLawZ_xX Scripting Help 21 26/11/2011 10:32 AM
Respawn vehicles grand.Theft.Otto Help Archive 1 04/08/2011 04:48 AM
Respawn all vehicles BP13 Help Archive 5 10/12/2009 03:39 PM
Vehicles don't respawn PoWerZ Help Archive 0 08/04/2009 08:48 AM


All times are GMT. The time now is 03:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.