SA-MP Forums Archive
Vehicle related issues - 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: Vehicle related issues (/showthread.php?tid=475292)



Vehicle related issues - EthanMason - 12.11.2013

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
     {
      new vehicle;
      vehicle = GetPlayerVehicleID(playerid);
      if(vehicle == Pizzabike1 || vehicle == Pizzabike2 || vehicle == Pizzabike3 || vehicle == Pizzabike4 || vehicle == Pizzabike5 || vehicle == Pizzabike6 && ispassenger == 0)
        {
        if ((Pizzajob) == 1)
           {
           SetPlayerCheckpoint(playerid, 1092.9705, -1093.6687, 25.5253, 5.0);
		   SendClientMessage(playerid,0xF5FF00FF, "[JOBHELP]:Use /deliverpizza to start your job");
		   KillTimer(Pizzatimer);
		   }
           else if ((Pizzajob) == 0)
		   {
	       RemovePlayerFromVehicle(playerid);
           }
        }
     }
  return 1;
}
So this is the "OnPlayerEnterVehicle function" No errors but it won't works in game ! i'm really confused since it's my first filterscript :/


Re: Vehicle related issues - Loot - 12.11.2013

What is the purpose of your code? To set a checkpoint before entering the vehicle, or after when you're driving in it?
Quote:
Originally Posted by Wiki
This callback is called when a player starts to enter a vehicle, meaning the player is not in vehicle yet at the time this callback is called.
Also, show me Pizzajob variable.


Re : Re: Vehicle related issues - EthanMason - 12.11.2013

Quote:
Originally Posted by Loot
Посмотреть сообщение
What is the purpose of your code? To set a checkpoint before entering the vehicle, or after when you're driving in it?
I want it to appear everytime i get on the pizza bike ! and if pizzajob= 0 the player get automaticlly ejected :P


Re: Vehicle related issues - dominik523 - 12.11.2013

You should create a command which will change Pizzajob to 1, also this variable has to be an array(Pizzajob[MAX_PLAYERS]) because you want to create it for every player. After the command you can add this under OnPlayerEnterVehicle:
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
     {
      new vehicle;
      vehicle = GetPlayerVehicleID(playerid);
      if(vehicle == Pizzabike1 || vehicle == Pizzabike2 || vehicle == Pizzabike3 || vehicle == Pizzabike4 || vehicle == Pizzabike5 || vehicle == Pizzabike6)
        {
        if ((Pizzajob[playerid]) == 1)
           {
           SetPlayerCheckpoint(playerid, 1092.9705, -1093.6687, 25.5253, 5.0);
		   CreateTimerEx("Pizzatimer",(time),false,"i",playerid); // I think you want to create timer here, not to kill it
		   }
           else if ((Pizzajob[playerid]) == 0)
		   {
	       RemovePlayerFromVehicle(playerid);
           }
        }
     }
  return 1;



Re : Vehicle related issues - EthanMason - 12.11.2013

i got this error
Код:
 error 028: invalid subscript (not an array or too many subscripts):"Pizzajob
i made this cmd to change Pizzajob to 1
Код:
 public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/joinjob", cmdtext, true, 10) == 0)
     {
       if (IsPlayerInRangeOfPoint(playerid, 3.0,2104.7783, -1797.8708, 13.5547))
         {
	       if ((Pizzajob[playerid]) == 0)
	        {
	           SendClientMessage(playerid, -1,"{00AFFF}[JOBHELP]:{FF0019}Congratulation, you have joined the Pizza boy job");
               Pizzajob = 1;
            }
            else if ((Pizzajob[playerid]) == 0)
            {
               SendClientMessage(playerid, -1,"{00AFFF}[JOBHELP]:{FF0019}You already joined this job");
	        }
         }
    }
Error line = red color
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
     {
      new vehicle;
      vehicle = GetPlayerVehicleID(playerid);
      if(vehicle == Pizzabike1 || vehicle == Pizzabike2 || vehicle == Pizzabike3 || vehicle == Pizzabike4 || vehicle == Pizzabike5 || vehicle == Pizzabike6)
        {
        if ((Pizzajob[playerid]) == 1)
           {
           SetPlayerCheckpoint(playerid, 1092.9705, -1093.6687, 25.5253, 5.0);
		   }
           else if ((Pizzajob[playerid]) == 0)
		   {
	       RemovePlayerFromVehicle(playerid);
           }
        }
     }
  return 1;
}



Re: Vehicle related issues - dominik523 - 12.11.2013

Код:
if (Pizzajob[playerid] == 1)
This should be fine. Also change every line where you have (Pizzajob[playerid]) == ...) to (Pizzajob[playerid] == ...)


Re : Vehicle related issues - EthanMason - 12.11.2013

Should i change new Pizzajob = 0 to new Pizzajob(MAX_PLAYERS) = 0; or ?


Re: Vehicle related issues - dominik523 - 12.11.2013

on the top of your script add
Код:
new Pizzajob[MAX_PLAYERS];
and you can add for example under OnPlayerConnect
Код:
Pizzajob[playerid] = 0;