SA-MP Forums Archive
rent car - 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: rent car (/showthread.php?tid=443152)



rent car - edzis84 - 10.06.2013

Hello!

Im making rent car system but i dont understand how can i make that no one can enter car if that is already rented.

Like this

P.S this code is just fast example, hope you understand me

Код:
CMD:rentcar(playerid,params[])
{
if(!IsRented(playerid)) return scm(playerid, -1, "This car is already rented);
{
SetRented to car !!!!!!!
SCM(playerid,-1,"You have rented this car");
return 1;
}

Onplayerenterveh
if(IsRented(playerid)) 
{
removeplayerfromveh

stock IsRented
SetRented to car !!!!!!!



Re: rent car - Sascha - 10.06.2013

you should not use "IsRented(playerid)" but "IsRented(vehicleid)"


Re: rent car - edzis84 - 10.06.2013

Can you give me code how can i set it to vehicleid?


Re: rent car - edzis84 - 10.06.2013

Anyone?


Re: rent car - Stefand - 11.06.2013

.... you might just want to look over tutorials... if you dont know how to change playerid in vehicleid...

SIMPLY REPLACE THE TEXT jeez

Its basic pawn..


Re: rent car - Sascha - 11.06.2013

<removed>

use a global variable...
soemthing like this:
Код:
new rented[MAX_VEHICLES];

public OnVehicleSpawn(vehicleid)
{
   rented[vehicleid] = 0;
   return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
   if(newstate == PLAYER_STATE_DRIVER)
   {
      new vehicleid = GetPlayerVehicleID(playerid);
      if(IsRented(vehicleid))
      {
         RemovePlayerFromVehicle(playerid);
      }
   }
   return 1;
}

stock IsRented(vehicleid)
{
   return rented[vehicleid];
}
and when a player rents a vehicle you ofc have to use:
Код:
rented[vehicleid] = 1;