SetVehicleParamsForPlayer
From SA-MP Wiki
SetVehicleParamsForPlayer
Set the parameters of a vehicle for a player.
(vehicleid,playerid,objective,doorslocked)
| vehicle | The ID of the vehicle to set the parameters of. |
| playerid | The ID of the player to set the vehiclle's parameters for. |
| objective | 0 to disable the objective or 1 to show it. |
| doorslocked | 0 to unlock the doors or 1 to lock them. |
This function does not return a specific value.
Note: You will have to respawn the vehicle to properly remove the objective.
Note: From 0.3 you will have to re-apply this function when OnVehicleStreamIn is called!
// Locks own car for all players, except the player who used the command. public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp(cmdtext,"/lock",true)) { if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); for(new i=0; i < MAX_PLAYERS; i++) { if(i == playerid) continue; SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i,0,1); } return 1; } return 0; }
// Will show vehicle markers for players streaming in for 0.3 new iVehicleObjective[MAX_VEHICLES][2]; public OnGameModeInit() //Or another callback { new temp = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 0,0, -1); //ID 1 iVehicleObjective[temp][0] = 1; //Marker iVehicleObjective[temp][1] = 0; //Door Lock return 1; } stock SetVehicleParamsForPlayerEx(vehicleid, playerid, objective, doorslocked) { SetVehicleParamsForPlayer(vehicleid, playerid, objective, doorslocked); iVehicleObjective[vehicleid][0] = objective; iVehicleObjective[vehicleid][1] = doorslocked; } public OnVehicleStreamIn(vehicleid, forplayerid) { SetVehicleParamsForPlayer(vehicleid, forplayerid, iVehicleObjective[vehicleid][0], iVehicleObjective[vehicleid][1]); }
Another way by theAlone
//Top new myMarkedCar; public OnGameModeInit() //Or another callback { myMarkedCar = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 0,0, -1); //For example: Black Landstalker near Blueberry Acres return 1; } //Whatever your want public OnVehicleStreamIn(vehicleid, forplayerid) { if(vehicleid == myMarkedCar) { SetVehicleParamsForPlayer(TmyMarkedCar, forplayerid, 1, 0); // marker can be visible only if the vehicle streamed for player } return 1; }
