OnPlayerStateChange Thing.
#1

How could I get it so that when a player enters a vehicle, a message comes up saying:
"Use /eon to turn on the vehicles engine!"

Thank you!
Reply
#2

pawn Код:
OnPlayerEnterVehicle(..)
{
     SendClientMessage(playerid, color, "Type /eon to turn on the vehicle's engine!");
     return 1;
}
Make sure you change "color" to one of your colors.
Reply
#3

Quote:
Originally Posted by austin070
Посмотреть сообщение
pawn Код:
OnPlayerEnterVehicle(..)
{
     SendClientMessage(playerid, color, "Type /eon to turn on the vehicle's engine!");
     return 1;
}
Make sure you change "color" to one of your colors.
C:\Documents and Settings\Callum\Desktop\lvrp\Windows\gamemodes\Vor texRoleplay.pwn(26412) : warning 225: unreachable code
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    {
     SendClientMessage(playerid, WHITE, "Type /eon to turn on the vehicle's engine!");
     return 1;
    }
    new model = GetVehicleModel(vehicleid);
    if(model == 596)
    {
        Player[playerid][GotInCopCar]++;
        ResetPlayerWeapons(playerid);
        GivePlayerSavedWeapons(playerid);
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by austin070
Посмотреть сообщение
pawn Код:
OnPlayerEnterVehicle(..)
{
     SendClientMessage(playerid, color, "Type /eon to turn on the vehicle's engine!");
     return 1;
}
Make sure you change "color" to one of your colors.
OnPlayerEnterVehicle will get called when the player is close enough from a vehicle and presses enter.

You can use OnPlayerStateChange to let the player know what to do when he is IN the vehicle.
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if ((newstate == PLAYER_STATE_DRIVER) && (oldstate == PLAYER_STATE_ONFOOT))
    {
        SendClientMessage(playerid, -1, "Type /eon to turn on the vehicle's engine!");
    }

    return 1;
}
Reply
#5

EDIT: They were faster.

Austin, it's:

public OnPlayerEnterVehicle(playerid)

or

public OnPlayerEnterVehicle(playerid, vehicleid)

Both possible.
@Getty:
You can use three things:
1) Check if the player press -ENTER-/F (not reccomended)
2) Use OnPlayerEnterVehicle:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    //The message here
    return 1;
}
3) I prefer this one. OnPlayerStateChange. Only show the message then if he's the driver!
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        //The message here
    }
    return 1;
}
Reply
#6

pawn Код:
if(newstate == 2)
            {
                 SendClientMessage(playerid, WHITE, "Type /eon to turf on the vehicle's engine!");
            }
            return 1;
        }
That doesn't work?
Reply
#7

Lol it always works for me.
Doesn't it work or do you get warnings/errors?

EDIT:
States are here btw: https://sampwiki.blast.hk/wiki/State
You could also try "5" (newstate == 5)
Reply
#8

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Lol it always works for me.
Doesn't it work or do you get warnings/errors?
It compiled alright mate, just when I go in game, I get nothing showing up.
Reply
#9

Quote:
Originally Posted by getty154
Посмотреть сообщение
C:\Documents and Settings\Callum\Desktop\lvrp\Windows\gamemodes\Vor texRoleplay.pwn(26412) : warning 225: unreachable code
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    {
     SendClientMessage(playerid, WHITE, "Type /eon to turn on the vehicle's engine!");
     return 1;
    }
    new model = GetVehicleModel(vehicleid);
    if(model == 596)
    {
        Player[playerid][GotInCopCar]++;
        ResetPlayerWeapons(playerid);
        GivePlayerSavedWeapons(playerid);
    }
    return 1;
}
Try:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new model = GetVehicleModel(vehicleid);
    if(model == 596)
    {
        Player[playerid][GotInCopCar]++;
        ResetPlayerWeapons(playerid);
        GivePlayerSavedWeapons(playerid);
    }
    SendClientMessage(playerid, WHITE, "Type /eon to turn on the vehicle's engine!");
    return 1;
}
Reply
#10

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Try:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new model = GetVehicleModel(vehicleid);
    if(model == 596)
    {
        Player[playerid][GotInCopCar]++;
        ResetPlayerWeapons(playerid);
        GivePlayerSavedWeapons(playerid);
    }
    SendClientMessage(playerid, WHITE, "Type /eon to turn on the vehicle's engine!");
    return 1;
}
I have tried this, and it works Stigg, I love you! N/H.

[ame="http://www.youtube.com/watch?v=bWEdkiQ16-g"]CLICK MEE[/ame]

That is what I was seeing!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)