[NEED HELP] - Player Variables for Trucking Job
#1

[SOLVED]
Reply
#2

Does anyone have any idea? If you need more detail, please let me know.
I haven't been able to come up with any solution.
Reply
#3

Let me tell if I understood right. You would like to create a trucking job and would like people who wants to be a trucker to be put in the pre-specified truck automatically, right ? If it's right what do you want us to do ? Put them inside or specifying the truck's idea ? I might be a bit helpless as i am in phone right now.

Edit: Seems like i completely messed lol. I am helpless in making a private truck for yourself. Sorry.
Reply
#4

Maybe something like this? It's just the basic structure, then you have to customize it:

pawn Код:
new UserTruck[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    UserTruck[playerid] = INVALID_VEHICLE_ID;
    return 1;
}
pawn Код:
// When a player starts his job and is put inside the truck:
UserTruck[playerid] = GetPlayerVehicleID(playerid);
pawn Код:
// When a player attempts to return a truck:
if(UserTruck[playerid] == GetPlayerVehicleID(playerid))
{
    // What should happen if the truck is his?
}
else
{
    // What should happen if the truck's ID doesn't match the player's truck ID? Maybe an error message for the player?
}
I hope I helped you.
Reply
#5

Quote:
Originally Posted by Rufio
Посмотреть сообщение
Let me tell if I understood right. You would like to create a trucking job and would like people who wants to be a trucker to be put in the pre-specified truck automatically, right ? If it's right what do you want us to do ? Put them inside or specifying the truck's idea ? I might be a bit helpless as i am in phone right now.

Edit: Seems like i completely messed lol. I am helpless in making a private truck for yourself. Sorry.
Any reply helps, no worries.

I mean I need to set a variable for that specific vehicle. I've already written the spawning and the PutPlayerInVehicle, etc... I just need a way for the player to basically... "temporarily own" the truck, so only they can use it. But when they /returntruck it will remove that variable.
Reply
#6

Quote:
Originally Posted by PHudson
Посмотреть сообщение
Maybe something like this? It's just the basic structure, then you have to customize it:

pawn Код:
new UserTruck[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    UserTruck[playerid] = INVALID_VEHICLE_ID;
    return 1;
}
pawn Код:
// When a player starts his job and is put inside the truck:
UserTruck[playerid] = GetPlayerVehicleID(playerid);
pawn Код:
// When a player attempts to return a truck:
if(UserTruck[playerid] == GetPlayerVehicleID(playerid))
{
    // What should happen if the truck is his?
}
else
{
    // What should happen if the truck's ID doesn't match the player's truck ID? Maybe an error message for the player?
}
I hope I helped you.
This is very close to what I'd need... I just need it to work in a way that every other player can't use the truck at all. I want only the spawner to be able to use it and return it.

EDIT: And since there will be around 10 truckers trucking at once, I need that to be possible, which is why I'm so stumped!
Reply
#7

Ok, simply add this to my code above:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    //if(!IsATruck(vehicleid)) return 1;                    Perhaps you don't want all vehicles to be restricted?
    if(!ispassenger && UserTruck[playerid] != vehicleid)
    {
        new Float:position[3];
        GetPlayerPos(playerid,position[0],position[1],position[2]);
        SetPlayerPos(playerid,position[0],position[1],position[2]+0.4);
    }
    return 1;
}
Reply
#8

Thank you very much! That seemed to do the trick!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)