attempt to enter wehicle.
#1

Hello there i have a question. i made like when player enter vehicle its locked and its tp him out... its tp him out when he is allready in i wish to create it ,its tp him out when he attempt to enter.

PHP код:
public SafeRemovePlayerFromVehicle(playerid)
{
    for(new 
i=0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
Spectate[i] != 255)
            {
                
PlayerSpectatePlayer(i,playerid);
            }
        }
    }
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playeridxyz);
    
TextDrawHideForPlayer(playeridTextdraw39[playerid]);
    
TextDrawHideForPlayer(playeridTextdraw40[playerid]);
    
TextDrawHideForPlayer(playeridTextdraw53[playerid]);
    
SafeSetPlayerPos(playerid,x,y-2z);
    return 
1;

Reply
#2

Use :
pawn Код:
ClearAnimations(playerid);
This will work.
Reply
#3

I don't get it. What you mean is when a player enter the vehicle which is currently locked then player should remove from the vehicle?
Reply
#4

its the same shit i had it before. i want when player try to open door its stop anim not when he is allready in
Reply
#5

Use
pawn Код:
OnPlayerEnterVehicle
callback
Reply
#6

On top of your script under the defines add this:
pawn Код:
new lockedvehicle[5];
new whatever[MAX_PLAYERS] = 0;
new status[MAX_PLAYERS] = 0;
Then in the Gamemodeinit add this, but make sure you edit it first orelse you will get warnings:

pawn Код:
lockedvehicle[0] = CreateVehicle(VEHICLEID, X, Y, Z, ROTATION, COLOR1, COLOR2, RESPAWNTIME); // defines locked vehicle number 1
    lockedvehicle[1] = CreateVehicle(VEHICLEID, X, Y, Z, ROTATION, COLOR1, COLOR2, RESPAWNTIME); // defines locked vehicle number 2
    lockedvehicle[2] = CreateVehicle(VEHICLEID, X, Y, Z, ROTATION, COLOR1, COLOR2, RESPAWNTIME); // defines locked vehicle number 3
    lockedvehicle[3] = CreateVehicle(VEHICLEID, X, Y, Z, ROTATION, COLOR1, COLOR2, RESPAWNTIME); // defines locked vehicle number 4
    lockedvehicle[4] = CreateVehicle(VEHICLEID, X, Y, Z, ROTATION, COLOR1, COLOR2, RESPAWNTIME); // defines locked vehicle number 5
Add this stock anywhere..
pawn Код:
stock IsALockedVehicle(vehicleid)
{
    for(new i;MAX_VEHICLES>i;i++)
    {
        if(vehicleid == lockedvehicle[i]) return 1;
    }
    return 0;
}
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger) return 1;
    if(IsALockedVehicle(vehicleid)) // if is a locked vehicle
    {
        if(whatever[playerid] != 1) // what ever variable you need is not 1
        {
            new Float:x, Float:y, Float:z;
            SendClientMessage(playerid, -1, "You can't enter this vehicle.");
            GetPlayerPos(playerid, x, y, z);
            SetPlayerPos(playerid, x, y, z+0.5);
        }
    }
    return 1;
}
Now, whenever you try to enter that vehicle it will deny you and say it is locked.
To unlock it, make some sort or command or any other function to unlock it for only that player id with
pawn Код:
whatever[playerid] = 1;
and lock it for that player again with
pawn Код:
whatever[playerid] = 0;
Example on OnPlayerCommandText

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/lock", cmdtext, true, 5) == 0)
    {
        if(status[playerid] == 0)
        {
            whatever[playerid] = 1;
            status[playerid] = 1;
            SendClientMessage(playerid, -1, "Unlocked.");
            return 1;
        }
        if(status[playerid] == 1)
        {
            whatever[playerid] = 0;
            status[playerid] = 0;
            SendClientMessage(playerid, -1, "Locked.");
            return 1;
        }
        return 1;
    }
    return 0;
}
The outcome is:

[ame]http://www.youtube.com/watch?v=YSe4l6ORlaM[/ame]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)