SetVehicleParamsForPlayer FR

From SA-MP Wiki

Jump to: navigation, search


Description:

Modifier les paramètres d'un véhicule pour un joueur (et uniquement pour ce joueur).


Paramètres:
(vehicleid, playerid, objective, doorslocked)
vehicleL'ID du véhicule dont on va modifier les paramètres.
playeridLe joueur qui subira les changements de paramètres du véhicule.
objective0 pour désactiver l'objectif ou 1 pour l'afficher.
doorslocked0 pour dé-verrouiller les portières ou 1 pour les verrouiller.


RetourneCette fonction ne retourne pas de valeur spécifique.


Image:32px-Ambox_warning_orange.png

Note

Vous devez faire ré-apparaître le véhicule pour enlever un objectif.


This can be circumvented somewhat using Get/SetVehicleParamsEx which do not require the vehicle to be respawned. It is worth noting however that the object will be disabled on a global scale, and this is only useful if only one player has the vehicle as an objective:

// sometime earlier:
SetVehicleParamsForPlayer(iPlayerVehicle, iPlayerID, 1, 0);
 
// sometime later when you want the vehicle to respawn:
new
	iEngine, iLights, iAlarm,
	iDoors, iBonnet, iBoot,
	iObjective;
 
GetVehicleParamsEx(iPlayerVehicle, iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, iObjective);
SetVehicleParamsEx(iPlayerVehicle, iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, 0);
Image:32px-Ambox_warning_orange.png

Note

Dans la 0.3 vous devez ré-appliquer ces fonctions quand OnVehicleStreamIn est appelé !


public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/lock",true)) 
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFAA,"Tu dois être dans un véhicule pour executer cette commande !");
        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 = AddStaticVehicleEx(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 = AddStaticVehicleEx(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(myMarkedCar, forplayerid, 1, 0); // marker can be visible only if the vehicle streamed for player
    }
    return 1;
}
Personal tools
Navigation
Toolbox