[HELP] Add function only owner of the vehicle or of the faction turn it on
#1

Hi, I'm using SC-RP script, help-me command engine just to owners or members of the faction turn it on.

Код:
CMD:motor(playerid, params[])
{
	new vehicleid = GetPlayerVehicleID(playerid);

	if (!IsEngineVehicle(vehicleid))
		return SendErrorMessage(playerid, "Vocк nгo estб em um veiculo.");

	if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
	    return SendErrorMessage(playerid, "Vocк nгo pode fazer isso porque nгo estб de motorista.");

	if (CoreVehicles[vehicleid][vehFuel] < 1)
	    return SendErrorMessage(playerid, "Este veiculo estб sem combustнvel.");

	if (ReturnVehicleHealth(vehicleid) <= 300)
	    return SendErrorMessage(playerid, "Este veiculo estб quebrado e nгo pode ser ligado.");

	switch (GetEngineStatus(vehicleid))
	{
	    case false:
	    {
	        SetEngineStatus(vehicleid, true);
	        //ShowPlayerFooter(playerid, "Voce ~g~ligou~w~ o motor!");
	        SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s insere a chave na igniзгo e liga o motor.", ReturnName(playerid, 0));
		}
		case true:
		{
		    SetEngineStatus(vehicleid, false);
		    //ShowPlayerFooter(playerid, "Voce ~r~desligou~w~ o motor!");
		    SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s gira a chave na igniзгo e desliga o motor.", ReturnName(playerid, 0));
		}
	}
	return 1;
}
Reply
#2

Check with an if statement if the player belong to specific faction or not?
Reply
#3

Yep, PlayerData[i][pFaction].
Reply
#4

HELP!!!
Reply
#5

up!!
Reply
#6

Create a new variable, under your player data enum.

Such as: pInfo[playerid][CarID] - so CarID,

Then link it to the vehicle ID as soon as their vehicle spawns.

Then on top of your motor command, input: if(vehicleid != pInfo[playerid][CarID]) return SendClientMessage(playerid, color, message);

Replace the above with your own code.

For factions, do the same, except detect if it's first a faction vehicle, and then create a car faction variable, and have faction car set to the faction's ID.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)