A simple question
#1

Hello, I'm working on a job system and i want to know if i do something like this:
Код:
new JobVehicle[MAX_PLAYERS];
Код HTML:
cmd:work(playerid,params[])
{
     JobVehicle[playerid] = CreateVehicle(411, ....bla.bla)
     return 1;
}
The variabile JobVehicle[playerid] become = with Vehicle Model or VehicleID ?
Reply
#2

Consult the wiki if unsure about a return value: https://sampwiki.blast.hk/wiki/CreateVehicle

Quote:

Return Values:
  • The vehicle ID of the vehicle created (1 to MAX_VEHICLES).
  • INVALID_VEHICLE_ID (65535) if vehicle was not created (vehicle limit reached or invalid vehicle model ID passed).
Reply
#3

Or, if you allow players to start work when they're already in a vehicle:
pawn Код:
CMD:work(playerid, params[])
{
   JobVehicle[playerid] = GetPlayerVehicleID(playerid);
   return 1;
}
This is the way i do it, the player must be in a vehicle to start it, so they get to pick the vehicle before starting the mission, this also means they're not being forced into a vehicle at the start of a mission
Reply
#4

Ah, ok, thanks, one more question, much problem

When a car is created, i set params for playerid like that:
Код:
SetVehicleParamsForPlayer(pJobVehicle[playerid],playerid, 0, 0);
And for others:
Код:
foreach(new x : Player)
		                {
		                	if(x != playerid)
		                	{
		                		SetVehicleParamsForPlayer(pJobVehicle[playerid], x, 0, 1);
		                	}
		                }
But i have this problem, it doesn't lock for anybody, can u help me?
Reply
#5

Put these things in OnVehicleStreamIn.
Reply
#6

pawn Код:
// Locks own car for all players, except the player who performs this
CMD:lock(playerid, params[])
{
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
        new Pool = GetPlayerPoolSize();
        for(new i = 0; i <= Pool; i++)
        {
            if(i == playerid) continue;
            SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i,0,1);
        }
        return 1;
}
I found this on the wiki, it might help you out alot.
If you make this into a command, like the example above, it'll lock the vehicle for everyone, except for the person who used the command

And as Vince said, you have to re-apply this at OnVehicleStreamIn
Source: https://sampwiki.blast.hk/wiki/SetVehicleParamsForPlayer
Reply
#7

I try first time
to put in command SetVehicleParamsEx and at OnVehicleStreamIn - SetVehicleParamsForPlayer

and it doesn't work. I have created a debug
Код:
printf("%i | %i", vehicleid, JobVehicle[forplayerid]);
Код:
[19:06:36] 439 | 439
It's respond but the door are still unlock.
Function SetVehicleParamsForPlayer is not called.
Reply
#8

become to be the vehicleid
Reply
#9

Anyway, i fix this. Thx for answs!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)