SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/12/2019, 01:21 AM   #1
albert12
Little Clucker
 
Join Date: Dec 2019
Location: Tunisia
Posts: 8
Reputation: 0
Default My /respawncars respawn used vehicles too...

Hello, i'm new with scripting and I can't actually code but i've succeeded on fixing bugs instead, you know it's all about switching values 1 to 0 and shit.. things like that
Anyways, this is my respawncar cmd from Horizon script, how can I make it not respawn used cars?

PHP Code:
CMD:respawncars(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 3)
    {
         if(
AdminDuty[playerid] != && PlayerInfo[playerid][pAdmin] < 4)
        {
            
SendClientMessage(playerid,COLOR_WHITE"You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
            return 
1;
        }

        new 
string[128], radius;
        if(
sscanf(params"d"radius)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /respawncars [radius]");

        if(
radius || radius 99999999)
        {
            
SendClientMessage(playeridCOLOR_WHITE"Radius must be higher than 0 and lower than 41!");
            return 
1;
        }
        
RespawnNearbyVehicles(playeridradius);
        
format(stringsizeof(string), "You have respawned all vehicles within a radius of %d."radius);
        
SendClientMessage(playeridCOLOR_GREYstring);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GRAD1"You are not authorized to use this command.");
    }
    return 
1;

albert12 is offline   Reply With Quote
Old 12/12/2019, 01:51 AM   #2
EAGLE
Little Clucker
 
Join Date: Nov 2019
Posts: 18
Reputation: 0
Default Re: My /respawncars respawn used vehicles too...

you need to check if a vehicle is used by player
EAGLE is offline   Reply With Quote
Old 12/12/2019, 06:01 AM   #3
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,593
Reputation: 379
Default Re: My /respawncars respawn used vehicles too...

You'll need to show us 'RespawnNearbyVehicles'
Joe Staff is offline   Reply With Quote
Old 12/12/2019, 09:25 AM   #4
Mattski
Big Clucker
 
Mattski's Avatar
 
Join Date: Oct 2019
Location: Under Your Moms Bed
Posts: 143
Reputation: 1
Default Re: My /respawncars respawn used vehicles too...

PHP Code:
    new bool:vehicleused[MAX_VEHICLES];
    for(new 
i=0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            
vehicleused[GetPlayerVehicleID(i)] = true;
        }
    }
    for(new 
i=1MAX_VEHICLESi++)
    {
        if(!
vehicleused[i])
        {
            
SetVehicleToRespawn(i);
        }
    } 
__________________

MY WORK:
Player Name Tags - https://pastebin.com/xncXzr0R
Mattski 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 Koreadars Scripting Help 5 15/04/2019 04:31 PM
CMD /respawncars with radius but I want respawn all cars JulianWilliams Scripting Help 6 12/01/2018 10:12 PM
Respawn Vehicles - Please Help M0HAMMAD Scripting Help 3 26/06/2014 10:08 AM
Respawn Vehicles don't respawn spawned cars JaKe Elite Scripting Help 6 20/05/2013 07:17 AM
Respawn vehicles grand.Theft.Otto Help Archive 1 04/08/2011 04:48 AM


All times are GMT. The time now is 02:04 PM.


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