SA-MP Forums Archive
Help with little code plz - 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: Help with little code plz (/showthread.php?tid=581644)



Help with little code plz - 123bob123 - 14.07.2015

How can I make it so when you enter a certain vehicle it gives you a message in the chat?

My code:

Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
  new v = GetVehicleModel(GetPlayerVehicleID(playerid));
  if(v == 455)
  {
	SendClientMessage(playerid, COLOR_YELLOW,"Go near the storage area and do /work to start your sidejob as a trucker!");
    return 1;
  }
}
Code error:

(449) : warning 209: function "OnPlayerEnterVehicle" should return a value


Re: Help with little code plz - notime - 14.07.2015

In between the 2 last closing brackets, put "return 1;" there.


Re: Help with little code plz - kyriakos587 - 14.07.2015

This will work..

Quote:

public OnPlayerEnterVehicle(playerid, vehicleid)
{
new v = GetVehicleModel(GetPlayerVehicleID(playerid));
if(v == 455)
{
SendClientMessage(playerid, COLOR_YELLOW,"Go near the storage area and do /work to start your sidejob as a trucker!");
return 1;
}
return 1;
}




Re: Help with little code plz - 123bob123 - 14.07.2015

didnt seem to work, nothing came in chat.


Re: Help with little code plz - Vince - 14.07.2015

OnPlayerEnterVehicle gets called when the player presses the key to enter a vehicle. The player is not actually in a vehicle at the point yet and the action can even be aborted. Hence GetPlayerVehicleID returns 0. I Don't know why you would need to use that function, seeing as you have a vehicleid parameter right there at your disposal.


Re: Help with little code plz - iMouiz - 14.07.2015

Try this:

Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
  new v = GetVehicleModel(GetPlayerVehicleID(playerid));
  if(v == 455)
  {
	SendClientMessage(playerid, COLOR_YELLOW,"Go near the storage area and do /work to start your sidejob as a   trucker!");
  }
  return 1;
}



Re: Help with little code plz - Sime30 - 14.07.2015

Quote:
Originally Posted by Vince
Посмотреть сообщение
OnPlayerEnterVehicle gets called when the player presses the key to enter a vehicle. The player is not actually in a vehicle at the point yet and the action can even be aborted. Hence GetPlayerVehicleID returns 0. I Don't know why you would need to use that function, seeing as you have a vehicleid parameter right there at your disposal.
Like Vince said, use vehicleid which is a part of OnPlayerEnterVehicle!


pawn Код:
new v = GetVehicleModel(vehicleid);



Re: Help with little code plz - 123bob123 - 15.07.2015

Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
  new v = GetVehicleModel(GetPlayerVehicleID(455));
  if(v == 455)
  {
	SendClientMessage(playerid, COLOR_YELLOW,"Go near the storage area and do /work to start your sidejob as a   trucker!");
	return 1;
  }
  return 1;
}
still didnt work


Re: Help with little code plz - notime - 15.07.2015

Quote:
Originally Posted by 123bob123
Посмотреть сообщение
Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
  new v = GetVehicleModel(GetPlayerVehicleID(455));
  if(v == 455)
  {
	SendClientMessage(playerid, COLOR_YELLOW,"Go near the storage area and do /work to start your sidejob as a   trucker!");
	return 1;
  }
  return 1;
}
still didnt work
It does work, only for playerid 455 though. The line:
pawn Код:
new v = GetVehicleModel(GetPlayerVehicleID(455));
Replace it with:
pawn Код:
new v = GetVehicleModel(vehicleid);
Someone already told you this..


Re: Help with little code plz - 123bob123 - 15.07.2015

thank you m8 i appricete it