SA-MP Forums Archive
respawn 1 vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: respawn 1 vehicle (/showthread.php?tid=387466)



respawn 1 vehicle - Stu1 - 24.10.2012

Hey, asking the community for a hand with something. I need to make a command that will respawn one car by id (/r id) i mean the id that is from /dl . I know how to respawn all vehicles, or a person model id but can someone give me some pointers on how to do this
Thanks. Of course i will +rep you if you help me


Re: respawn 1 vehicle - PaulDinam - 24.10.2012

Something like that?
Код:
if(IsPlayerInAnyVehicle(playerid))
{
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, COLOR_GREY, "Vehicle Respawned!");
}



Re: respawn 1 vehicle - ThePhenix - 24.10.2012

You Need sscanf.
PHP код:
CMD:svplayeridparams[ ] )
{
    static
        
vehID
    
;
    if ( 
sscanfparams"i",  vehID ) )
        return 
SendClientMessageplayeridCOLOR_RED"SYNTAX: /sv < vehID >" );
    if ( 
vehID == INVALID_VEHICLE_ID )
        return 
SendClientMessageplayeridCOLOR_RED"ERROR: Invalid vehicle ID." );
    
SetVehicleToRespawnvehID );
    
SendClientMessageplayeridCOLOR_RED"Vehicle has been respawned succesfully." );
    return 
1;




Re: respawn 1 vehicle - KevinPRINCE - 24.10.2012

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
You Need sscanf.

Not really you can do it with "SetVehicleToRespawn"

Edit: From A_SAMP


Re: respawn 1 vehicle - Stu1 - 24.10.2012

I had no luck with that, do i need to get the vehicle id first?


Re: respawn 1 vehicle - KevinPRINCE - 24.10.2012

Quote:
Originally Posted by Stu1
Посмотреть сообщение
I had no luck with that, do i need to get the vehicle id first?
Yes because or else system won't know which vehicle you want!


Re: respawn 1 vehicle - Stu1 - 24.10.2012

Thats the bit i had a problem with! I can only get a vehicle id that a player is using and i Dont need that


Re: respawn 1 vehicle - KevinPRINCE - 24.10.2012

Quote:
Originally Posted by Stu1
Посмотреть сообщение
Thats the bit i had a problem with! I can only get a vehicle id that a player is using and i Dont need that
You want something like this?

PHP код:
if(strcmp(cmd"/rac"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pAdmin] < 1337)
            {
                
SendClientMessage(playeridCOLOR_GRAD1" You are not authorized to use that command");
                return 
1;
            }
            new 
bool:unwanted[CAR_AMOUNT];
            for(new 
player=0player<MAX_PLAYERSplayer++)
             {
                if(
IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
             }
            for(new 
car 1car <= 699car++)
            {
                if(!
unwanted[car]) SetVehicleToRespawn(car);
            }
            
format(stringsizeof(string), "AdmWarning: %s(%d) has respawned all the cars!"sendername,playerid);
            
ABroadCast(COLOR_LIGHTRED,string1);
        }
        return 
1;
    } 



Re: respawn 1 vehicle - Stu1 - 24.10.2012

That will restore all cars though right? I'm looking to do just the one, say a player finds a car or trailer blocking the road he/she can go /dl get the id and tell a admin to restore it. With /r [vehicleid]


Re: respawn 1 vehicle - KevinPRINCE - 24.10.2012

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
You Need sscanf.
PHP код:
CMD:svplayeridparams[ ] )
{
    static
        
vehID
    
;
    if ( 
sscanfparams"i",  vehID ) )
        return 
SendClientMessageplayeridCOLOR_RED"SYNTAX: /sv < vehID >" );
    if ( 
vehID == INVALID_VEHICLE_ID )
        return 
SendClientMessageplayeridCOLOR_RED"ERROR: Invalid vehicle ID." );
    
SetVehicleToRespawnvehID );
    
SendClientMessageplayeridCOLOR_RED"Vehicle has been respawned succesfully." );
    return 
1;

DO this one