SA-MP Forums Archive
vehicle "is"... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: vehicle "is"... (/showthread.php?tid=128584)



vehicle "is"... - falor - 18.02.2010

Hey guys,
I try to code my server's vehicles to be used just by one faction for exemple.

I try this :
Код:
forward IsAVelib(vehicleid);
Код:
public IsAVelib(vehicleid)
{
   if(GetVehicleModel(vehicleid) >268 && GetVehicleModel(vehicleid) < 280 )
   {
      return 1;
   }
   else return 0;
}
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	passenger[playerid] = ispassenger;
		if (IsAVelib(vehicleid) && !ispassenger)
		{
        SendClientMessage(playerid,COLOR_GREY, "TEST");
		GivePlayerMoney(playerid, -100);

		}
But when i go to a "velib" it has no effect at all.
I hope you'll be able to help me, thank you !


Re: vehicle "is"... - Ricop522 - 18.02.2010

Quote:
Originally Posted by falor
Hey guys,
I try to code my server's vehicles to be used just by one faction for exemple.

I try this :
Код:
forward IsAVelib(vehicleid);
Код:
public IsAVelib(vehicleid)
{
  if(GetVehicleModel(vehicleid) >268 && GetVehicleModel(vehicleid) < 280 )
  {
     return 1;
  }
  else return 0;
}
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	passenger[playerid] = ispassenger;
		if (IsAVelib(vehicleid) && !ispassenger)
		{
       SendClientMessage(playerid,COLOR_GREY, "TEST");
		GivePlayerMoney(playerid, -100);

		}
But when i go to a "velib" it has no effect at all.
I hope you'll be able to help me, thank you !
forward IsAVelibCar(carid);

else if(IsAVelibCar(newcar))
{
SendClientMessage(playerid,COLOR_GREY, "TEST");
GivePlayerMoney(playerid, -100);
}

public IsAVelibCar(carid)
{
if((carid == id) || (carid == id) || (carid == id) || (carid == id) || (carid == id) || (carid == id) || (carid == id) || (carid == id))
{
return 1;
}
return 0;
}



Re: vehicle "is"... - falor - 18.02.2010

Thanks i'll do it.
I can't use < and > ?
Because type 20bikes is very long + the police cars etc...


Re: vehicle "is"... - saiberfun - 18.02.2010

Quote:
Originally Posted by falor
Thanks i'll do it.
I can't use < and > ?
Because type 20bikes is very long + the police cars etc...
> = "1. is bigger than 2. variable"
< = "1. is smaller than 2. variable"
== = "1. is equal to 2. variable"


Re: vehicle "is"... - falor - 18.02.2010

I know, but can i set like that
Код:
 public IsAVelibCar(carid)
{
  if((carid > 260 && carid < 280) )
  {
   return 1;
  }
  return 0;
}
?



Re: vehicle "is"... - saiberfun - 18.02.2010

Quote:
Originally Posted by falor
I know, but can i set like that
Код:
 public IsAVelibCar(carid)
{
 if((carid > 260 && carid < 280) )
 {
   return 1;
 }
 return 0;
}
?
use onplayerstate change
its called while entering
onplayerenter vehicle is called when he just entered.
https://sampwiki.blast.hk/wiki/Playerstates


Re: vehicle "is"... - falor - 18.02.2010

Thanks for you help

Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
  new state = GetPlayerState(playerid);
if (state == PLAYER_STATE_PASSENGER || state == PLAYER_STATE_DRIVER)
  {
  if((carid > 260 && carid < 280) )
  {
   GivePlayerMoney(playerid, -100);
   return 1;
  }
  return 0;
}
 
  return 1;
}
like that it will be fine?




Re: vehicle "is"... - Correlli - 18.02.2010

No, it won't. You'll need to check for the newstate and you'll need to define your carid variable.


Re: vehicle "is"... - falor - 18.02.2010

Wow, it beghins to be hard, i don't know how to do that
I should set : if IsaVelib ?
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
  new state = GetPlayerState(playerid);
if (state == PLAYER_STATE_PASSENGER || state == PLAYER_STATE_DRIVER)
  {
  if(IsAVelibCar)
  {
   GivePlayerMoney(playerid, -100);
   return 1;
  }
  return 0;
}
 
  return 1;
}
?




Re: vehicle "is"... - pyrodave - 18.02.2010

You're using the wrong function, GetVehicleModel returns a modelid of the vehicle, a list of model ids is here:

https://sampwiki.blast.hk/wiki/Vehicles:All

If you just want vehicleid, then use this instead:

pawn Код:
public IsAVelib(vehicleid)
{
   if(vehicleid > 268 && vehicleid < 280)
   {
      return 1;
   }
   else return 0;
}
Providing the vehicles you want to check have that ID.