Little Help
#1

Hello I made new system which is for vehicles.When you find some amount of materials you will get some keys for bobcat example.But when I don`t have keys it`s unlocked...why

code:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 422)
    {
        if(UserStats[playerid][KeysBob] == 0)
        {
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vehicleid,engine,lights,alarm,0,bonnet,boot,objective);
        }
        else
        {
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vehicleid,engine,lights,alarm,1,bonnet,boot,objective);
        }
    }
    return 1;
}
Reply
#2

Try
Код:
SetVehicleParamsForPlayer(vehicleid, playerid, objective, doorslocked);
Reply
#3

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Try
Код:
SetVehicleParamsForPlayer(vehicleid, playerid, objective, doorslocked);
It`s not working
Reply
#4

I try this too but still not working ((

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 422)
    {
        if(UserStats[playerid][KeysBob] == 0)
        {
            SetVehicleParamsForPlayer(vehicleid, playerid, 0, 1);
        }
        else
        {
            SetVehicleParamsForPlayer(vehicleid, playerid, 0, 0);
        }
    }
    return 1;
}
Anyone can help me?
Reply
#5

There's no no point in creating the same two variables for the same use. Just create them once. You could try it like this:

pawn Код:
if(UserStats[playerid][KeysBob] == 0)
{
    // your code...
}
if(UserStats[playerid][KeysBob] == 1)
{
    // your code...
}
Reply
#6

Quote:
Originally Posted by Unte99
Посмотреть сообщение
There's no no point in creating the same two variables for the same use. Just create them once. You could try it like this:

pawn Код:
if(UserStats[playerid][KeysBob] == 0)
{
    // your code...
}
if(UserStats[playerid][KeysBob] == 1)
{
    // your code...
}
It`s still no locked!I don`t know why..
Reply
#7

Sorry, I was about to post my solution but SAMP forums decided to have a maintenance...
Here it is:
pawn Код:
public OnFilterScriptInit() //Or OnGameModeInit() if you're using a gamemode
{
    SetTimer("BobCheck", 1000, true);
    return 1;
}

forward BobCheck();
public BobCheck()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            for(new v = 0; v < MAX_VEHICLES; v++)
            {
                if(GetVehicleModel(v) == 422)
                {
                    if(UserStats[i][KeysBob] == 1) //If they have keys
                    {
                        SetVehicleParamsForPlayer(v, i, 0, 0); //Unlock Vehicle (Bobcat)
                    }
                    else
                    {
                        SetVehicleParamsForPlayer(v, i, 0, 1); //Lock Vehicle (Bobcat)
                    }
                }
            }
        }
    }
    return 1;
}
I also noticed you were trying to use vehicle == 422. I used to do this when I was new to scripting, this is probably where your script was screwing up. You need to use GetVehicleModel if you're trying to get the actual Model ID. Example: The Vehicle model for NRG is 522. The Vehicle model for Infernus is 411. However, vehicle model and vehicle ID are two different things. So in this case, you should have used if(GetVehicleModel(vehicleid) == 422)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)