OnPlayerEnterVehicle (Message)
#1

Hi guys.
I've try to send a message to the person who enters any vehicle as a driver. I tried this: https://sampforum.blast.hk/showthread.php?tid=254723
and not works, wouldn't compile.

I use strange gamemode, where my OnPlayerEnterVehicle function is other than link typed up.
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

	if(ispassenger)
	{
		if(GetVehicleModel(vehicleid) == 519)
		{
			IsInShml[playerid]=vehicleid;

			SetPlayerFacingAngle(playerid, 0);
			SetCameraBehindPlayer(playerid);

			SetPlayerInterior(playerid, 1);
			SetPlayerPos(playerid, 1.5527,32.4773,1199.5938);

		}
		return 1;
	}

	if(vehicleid < MaxPojazdow) return 1;

	for(new x=0;x<HOUSES_LOOP;x++){
		if(vehicleid == HouseInfo[x][hCarid]){

			if(HouseID[playerid] != x){
				SendClientMessage(playerid,COLOR_RED2,"To jest prywatny pojazd!");
				SendClientMessage(playerid,COLOR_RED2,"Aby taki mieć musisz kupić dom  /Kupdom");
				new Float:fx,Float:y,Float:z;
				GetPlayerPos(playerid,fx,y,z);
				SetPlayerPos(playerid,fx,y,z+2);
				break;
			}

		}
	}

	
	return 1;
}
Anyone know how help me? ;/
Reply
#2

If this is the message that you want to show
pawn Код:
SendClientMessage(playerid,COLOR_RED2,"To jest prywatny pojazd!");
                SendClientMessage(playerid,COLOR_RED2,"Aby taki mieć musisz kupić dom  /Kupdom");
Then it actually shows when player is in House Vehicle... If you wanted that, than i think this is problem
pawn Код:
if(HouseID[playerid] != x){
because i don't know what this function does...
Reply
#3

No no no,
I want to send message to players who enter vehicle with information about available commands by use SendClientMessage function, similarly like in linked thread.
Reply
#4

Than all you have to do is under OnPlayerEnterVehicle to put the SendClientMessage function.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    SendClientMessage(playerid,COLOR_RED2,"YOUR MESSAGE HERE");

    if(ispassenger)
    {
        if(GetVehicleModel(vehicleid) == 519)
        {
//REST OF YOUR CODE
Reply
#5

That's is it!
Thanks, but.. "message" shows if push Enter to vehicle button (when I push 3 times, message shows too 3x).
Maybe some timer to lock reshow message? Can you do that?
Reply
#6

I'm not proffesional scripter but if i was you, i would make like this:
pawn Код:
//Put this on top of your gamemode
forward MessageTimer(playerid);
new AlreadyShowed[MAX_PLAYERS];

//Under OnPlayerEnterVehicle
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(AlreadyShowed[playerid] == 0)
    {
        AlreadyShowed[playerid] = 1;
        SendClientMessage(playerid,COLOR_RED2,"YOUR MESSAGE HERE");
        SetTimerEx("MessageTimer", 5000, false, "i", playerid); // change 5000 if you want :)
    }
    //rest of your code
}

//Somewhere in your gamemode
public MessageTimer(playerid)
{
    AlreadyShowed[playerid] = 0;
    return 1;
}
Reply
#7

Quote:
Originally Posted by NeroX98
Посмотреть сообщение
I'm not proffesional scripter
Da best, works.
Thanks dude!!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)