vehicle "is"...
#1

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 !
Reply
#2

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;
}
Reply
#3

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

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"
Reply
#5

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

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
Reply
#7

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?

Reply
#8

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

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;
}
?

Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)