Removing a player's weapon on vehicle enter/exit?
#1

Basically whenever a player gets into a faction vehicle and gets out, their weapons disappear. I have looked up and down the script and could not pinpoint the situation, only a suspected location here:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    new string[128];
   
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(Vehicles[vehicleid][CarJob])
        {
            SendClientMessage(playerid, GREY, "NOTICE: You have entered a side-job car. Using this for personal usage will result in an A-jail.");
        }
        SavePlayerData(playerid);
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        if(engine == 0) {
        SendClientMessage(playerid, WHITE, "To start your vehicle's engine, use {00FF00}SPACE");
        }
        if(floatround(Vehicles[GetPlayerVehicleID(playerid)][Fuel]) <= 0)
        {
            format(string,sizeof(string),"~g~ Fuel: ~w~ 0");
            SendClientMessage(playerid, COLOR_RED, "This vehicle has ran out of fuel");
            KillTimer(FuelTimer[playerid]);
            ToggleVehicleEngine(GetPlayerVehicleID(playerid), false);
            TextDrawSetString(FuelText[playerid], string);
            TextDrawShowForPlayer(playerid, SpeedText[playerid]);
            SpeedTimer[playerid] = SetTimerEx("SpeedUpdate", 1000, true, "i", playerid);
            TextDrawSetString(SpeedText[playerid], string);
            TextDrawShowForPlayer(playerid, SpeedText[playerid]);
        }
        else
        {
            FuelTimer[playerid] = SetTimerEx("FuelDown", 1000, true, "i", playerid); // Fueldown timer
            TextDrawShowForPlayer(playerid, FuelText[playerid]);
            TextDrawShowForPlayer(playerid, SpeedText[playerid]);
            SpeedTimer[playerid] = SetTimerEx("SpeedUpdate", 1000, true, "i", playerid);
            TextDrawSetString(SpeedText[playerid], string);
            TextDrawShowForPlayer(playerid, SpeedText[playerid]);
        }
    }
    else
    {
        TextDrawHideForPlayer(playerid,FuelText[playerid]);
        TextDrawSetString(FuelText[playerid], "         ");
    }
   
    if ((oldstate == PLAYER_STATE_DRIVER) && (newstate == PLAYER_STATE_ONFOOT))
    {
        TextDrawHideForPlayer(playerid, FuelText[playerid]);
        TextDrawHideForPlayer(playerid, SpeedText[playerid]);
    }
   
    if ((oldstate == PLAYER_STATE_DRIVER) && (newstate == PLAYER_STATE_DRIVER))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new Float:health;
        GetVehicleHealth(vehicleid, health);
        if(vehEngine[vehicleid] == 1)
        {
            if(health > 300)
            {
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
                vehEngine[vehicleid] = 0;
                format(string, sizeof(string), "* A loud BANG sound is heard from %s's vehicle as it rolls to a dead stop.", pRPName(playerid));
                NearByMessage(playerid, 0xFFA8FFFF, string);
                SendClientMessage(playerid, RED, "Your vehicle has taken too much damage and will not go any further!");
            }
        }
    }
   
    if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_DRIVER))
    {
       
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 511)
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
            vehEngine[vehicleid] = 1;
        }
    }
    if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_DRIVER))
    {
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 438)
        {
            if(Jobs[Player[playerid][Job]][JobType] == 9)
            {
                SendClientMessage(playerid, GREY, "You may now go on Taxi Duty via /taxiduty!");
            }
            else
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, GREY, "You do not have the keys to this vehicle! (You must be a taxi driver)");
            }
        }
    }
    if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER))
    {
         OldVehID [playerid] = GetPlayerVehicleID (playerid);
    }
    new vehicleid = GetPlayerVehicleID(playerid);
    new Float:health;
    GetVehicleHealth(vehicleid, health);
    if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        new string2[128];
        new PlayerVehicle = GetVehicleFileID(GetPlayerVehicleID(playerid));
        if(Vehicles[PlayerVehicle][CarGroup] != 0 && Vehicles[PlayerVehicle][CarGroup] != Player[playerid][Group])
        {
            format(string2, sizeof(string2), "This vehicle is only usable by %s.", Groups[Vehicles[PlayerVehicle][CarGroup]][GroupName]);
            SendClientMessage(playerid, WHITE, string2);
            RemovePlayerFromVehicle(playerid);
        }
        else if(IsAnOwnedCar(vehicleid))
        {
            if(Player[playerid][AdminLevel] < 1)
            {
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(Player[i][LockedCar] == 1 && Player[i][CarLinkID] == vehicleid)
                    {
                        SendClientMessage(playerid, WHITE, "This vehicle is locked.");
                        RemovePlayerFromVehicle(i);
                    }
                    if(Player[i][LockedCar2] == 1 && Player[i][Car2LinkID] == vehicleid)
                    {
                        SendClientMessage(playerid, WHITE, "This vehicle is locked.");
                        RemovePlayerFromVehicle(i);
                    }
                    if(Player[i][LockedCar3] == 1 && Player[i][Car3LinkID] == vehicleid)
                    {
                        SendClientMessage(playerid, WHITE, "This vehicle is locked.");
                        RemovePlayerFromVehicle(i);
                    }
                }
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
Removing a player's weapon on vehicle enter/exit? - by nmader - 17.09.2012, 00:58
Re: Removing a player's weapon on vehicle enter/exit? - by clarencecuzz - 17.09.2012, 06:36
Re: Removing a player's weapon on vehicle enter/exit? - by nmader - 17.09.2012, 12:04

Forum Jump:


Users browsing this thread: 1 Guest(s)