SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 06/12/2019, 07:32 AM   #1
zowzow
Little Clucker
 
Join Date: Nov 2018
Location: Ifa4uu9T36
Posts: 32
Reputation: 0
Default Respawn vehicle except rental car

I want to respawn vehicle by command but except rental car
Now I have this one

Code:
CMD:recar(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
		for(new c = 0; c < MAX_VEHICLES; c++)
		{
			if(c != INVALID_VEHICLE_ID)
			{
				if(!IsVehicleEmpty(c)) {
					SetVehicleToRespawn(c);
				}
			}
		}
	}
	return 1;
}
And here my rental car variable

Code:
DestroyVehicle(RentBike[playerid]);
RentBike[playerid] = CreateVehicle(462, 1742.8875,-1857.3384,13.0121,271.6042, 1, 1, 100);
PutPlayerInVehicle(playerid, RentBike[playerid], 0);
I have no idea how to do it or any suggest please?
zowzow is offline   Reply With Quote
Old 06/12/2019, 11:40 AM   #2
l0gic
Little Clucker
 
Join Date: Aug 2019
Posts: 7
Reputation: 0
Default Re: Respawn vehicle except rental car

You don't have to check if player is connected to server when its obvious player is in the server entering commands.
I would make vehicle data array where every vehicle information is stored and every vehicle has owner type flag.
foreach / y_iterate: https://forum.sa-mp.com/showthread.php?t=571159
PHP Code:
#include <YSI_Data\y_iterate>   //iterating through arrays

//these are possible vehicle rent types
#define veh_owner_player    0
#define veh_owner_rent      1

//vehicles information is stored here
enum eVehicle{
    
ModelID,
    
OwnerType,
    
OwnerID,
Slot
    
//etc other vehicle related params
};
new 
Vehicle[MAX_VEHICLES][eVehicle],
    
//foreah makes looping through vehicles array much faster and simplier
    
Iterator:fVehicles<MAX_VEHICLES>;   

CMD:respawnvehs(pid){
    
//looping through vehicle array
    
foreach(new fVehicles){
        
//checks that vehicle isn't rentable
        
if(Vehicle[i][OwnerType] != veh_owner_rent){
            
SetVehicleToRespawn(Vehicle[i][Slot]);
        }
    }
    return 
1;

l0gic is offline   Reply With Quote
Old 06/12/2019, 11:50 AM   #3
zowzow
Little Clucker
 
Join Date: Nov 2018
Location: Ifa4uu9T36
Posts: 32
Reputation: 0
Default Re: Respawn vehicle except rental car

thank for the idea
Now I got this and its worked

Code:
CMD:recar(playerid, params[])
{
	if(!pInfo[playerid][Login])
		return 1;

	if(pInfo[playerid][Admin] < 5)
		return 1;

    foreach(new i : Player)
    {
		for(new c = 0; c < MAX_VEHICLES; c++)
		{
			if(c != RentBike[i])
			{
				if(!IsVehicleEmpty(c)) {
					SetVehicleToRespawn(c);
				}
			}
		}
	}
	return 1;
}
zowzow is offline   Reply With Quote
Old 06/12/2019, 11:53 AM   #4
l0gic
Little Clucker
 
Join Date: Aug 2019
Posts: 7
Reputation: 0
Default Re: Respawn vehicle except rental car

Please the last code you send, doesn't even make any sense. You are looping throught players and everytime respawning vehicles
l0gic is offline   Reply With Quote
Old 06/12/2019, 01:12 PM   #5
zowzow
Little Clucker
 
Join Date: Nov 2018
Location: Ifa4uu9T36
Posts: 32
Reputation: 0
Default Re: Respawn vehicle except rental car

Sorry and ty for your helping
I actually dont know how to do that I mean I'm new with YSI
And I dont know how to convert it to your code

Code:
Dialog:DIALOG_RENTBIKE(playerid, response, listitem, inputtext[])
{
	if(response)
	{
		switch(listitem)
		{
			case 0:
			{
			    if(GetMoney(playerid) > 500)
			    {
			        DestroyVehicle(RentBike[playerid]);
       				RentBike[playerid] = CreateVehicle(462, 1742.8875,-1857.3384,13.0121,271.6042, 1, 1, 100);
       				PutPlayerInVehicle(playerid, RentBike[playerid], 0);
       				RentBikeTime[playerid] = 1800; // 1800
       				GiveMoney(playerid, -500);
       				SendClientMessage(playerid, COLOR_GREY, " You did it");
			    }
			}
		}
	}
	return 1;
}
zowzow 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
Vehicle respawn Heress Scripting Help 2 22/05/2019 03:48 PM
[FilterScript] adm_Rent | Create easy rental vehicles! | 1 line: 1 rental car admantis Filterscripts 21 10/07/2014 03:32 PM
Respawn vehicle Sliceofdeath Scripting Help 1 01/10/2013 07:51 AM
Vehicle respawn FalconWingsX Scripting Help 0 10/11/2012 11:55 AM
Vehicle respawn Aguylera Help Archive 3 31/10/2010 01:52 PM


All times are GMT. The time now is 04:53 AM.


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