Removing player from hydra if GetPlayerScore(playerid) <- 1000
#1

Hello mates!
So, I would want someone to give me a snippet or maybe explain me how to remove a player if his scores are less than 1000 from a hydra (if he enters it ofc!).

Any help would be appreciated!
Reply
#2

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 520) // 520 is hydra
    {
        if(GetPlayerScore(playerid) < 1000)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, 0xFFFFFFFF, "You are not allowed to use hydra!");
        }
    }
    return 1;
}
Reply
#3

EDIT: Too Late
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 520 && !ispassenger) //Check if the vehicle is Hydra and he's not passenger
    {
        if(GetPlayerScore(playerid) < 1000) //YOUR variable here, I dont know your variable, so I use this
        {
            RemovePlayerFromVehicle(playerid);
            //send message or whatever
        }
    }
    return 1;
}
Reply
#4

Thank you both for your answers! And thank you RenovanZ for your explanation! I would like to ask for one more thing.

Could you please do it so like if a player have 1000 scores and IS a part of gTeam[playerid] == ARMY_PILOT then let him enter the hydra, else remove him

Thank you!
Reply
#5

OnPlayerEnterVehicle is called when a player BEGINS to enter a vehicle, not when he has actually entered it.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate & PLAYER_STATE_DRIVER) //If the player entered as a driver
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 520) //If the vehicle is a hydra
        {
            if(GetPlayerScore(playerid) < 1000 || gTeam[playerid] != ARMY_PILOT) //If their score is less than 100
            {
                RemovePlayerFromVehicle(playerid); //Remove them from the vehicle
                SendClientMessage(playerid, -1, "You must have 1000 score and be an army pilot to be able to use this vehicle.");
            }
        }
    }
    return 1;
}
Sources:
https://sampwiki.blast.hk/wiki/OnPlayerStateChange
https://sampwiki.blast.hk/wiki/RemovePlayerFromVehicle
https://sampwiki.blast.hk/wiki/GetPlayerScore
https://sampwiki.blast.hk/wiki/GetVehicleModel
https://sampwiki.blast.hk/wiki/GetPlayerVehicleID
Reply
#6

@Threshold - Thank you very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)