Help with little code plz
#1

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

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

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

Reply
#4

didnt seem to work, nothing came in chat.
Reply
#5

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

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

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);
Reply
#8

Код:
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
Reply
#9

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

thank you m8 i appricete it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)