if(motor[i] == 1)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Ligado");
}
else if(motor[i] == 0)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Desligado");
}
TextDrawSetString(MotorOnOFF[i], velopet5);
motor[playerid] = 0; // desligado
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
if(motor[playerid] == 1){ Funзгo.. }
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, suatxd);
motor[playerid] = 0;
}
return 1;
}
Exemplo:
pawn Код:
|
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) // Essa funзгo vai verificar se o player й motorista ou passageiro de um veнculo, se ele for vai executar a funзгo abaixo:
{
if(motor[playerid] == 1){ Funзгo.. } // Se a variбvel motor for igual a 1 ele vai executar oque tб dentro do { }. Um exemplo й chamar uma callback..
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) // Essa funзгo verifica se o player nгo й mais o motorista do veнculo. Se ele nao for motorista / passageiro vai executar as funзхes abaixo:
{
TextDrawHideForPlayer(playerid, suatxd); // vai esconder a textdraw que mostra o motor ligado
motor[playerid] = 0; // vai setar a variбvel para 0..
}
return 1;
}
Exemplo:
pawn Код:
|
if (strcmp("/motor", cmdtext, true, 10) == 0)
{
new State;
new mot, lu, alar, por, cap, porma, ob;
new carro = GetPlayerVehicleID(playerid);
if(carro != INVALID_VEHICLE_ID)
{
if(IsPlayerInAnyVehicle(playerid))
{
State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
MSGPLAYER(playerid,COLOR_GREY," Vocк nгo й o motorista/piloto do veнculo");
return 1;
}
if(motor[playerid] == 0)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
motor[playerid] = 1;
SendClientMessage(playerid, 0xFFFFFFAA, "Veiculo {2F991A}Ligado, {FFFFFF}Digite /motor para desliga-lo");
}
else if(motor[playerid] == 1)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
motor[playerid] = 0;
SendClientMessage(playerid, 0xFFFFFFAA, "Veiculo {E31919}Desligado, {FFFFFF}Digite /motor para liga-lo");
}
}
}
return 1;
}
if(motor[i] == 1)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Ligado");
motor[playerid] = 1; // ligado
}
else if(motor[i] == 0)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Desligado");
motor[playerid] = 0; // desligado
}
TextDrawSetString(MotorOnOFF[i], velopet5);
forward sismotor(playerid); // topo do gamemode
if (strcmp("/motor", cmdtext, true, 10) == 0)
{
new State;
new mot, lu, alar, por, cap, porma, ob;
new carro = GetPlayerVehicleID(playerid);
if(carro != INVALID_VEHICLE_ID)
{
if(IsPlayerInAnyVehicle(playerid))
{
State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
MSGPLAYER(playerid,COLOR_GREY," Vocк nгo й o motorista/piloto do veнculo");
return 1;
}
if(motor[playerid] == 0)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
motor[playerid] = 1;
SendClientMessage(playerid, 0xFFFFFFAA, "Veiculo {2F991A}Ligado, {FFFFFF}Digite /motor para desliga-lo");
}
else if(motor[playerid] == 1)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
motor[playerid] = 0;
SendClientMessage(playerid, 0xFFFFFFAA, "Veiculo {E31919}Desligado, {FFFFFF}Digite /motor para liga-lo");
}
}
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
if(motor[playerid] == 1){ sismotor(playerid); }
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, MotorOnOFF[i]);
motor[playerid] = 0;
}
return 1;
}
public sismotor(playerid)
{
if(motor[i] == 1)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Ligado");
motor[playerid] = 1; // ligado
}
else if(motor[i] == 0)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Desligado");
motor[playerid] = 0; // desligado
}
TextDrawSetString(MotorOnOFF[i], velopet5);
return 1
}
Tenta assim:
pawn Код:
|
forward sismotor(playerid); // topo do gamemode
if (strcmp("/motor", cmdtext, true, 10) == 0)
{
new State;
new mot, lu, alar, por, cap, porma, ob;
new carro = GetPlayerVehicleID(playerid);
if(carro != INVALID_VEHICLE_ID)
{
if(IsPlayerInAnyVehicle(playerid))
{
State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
MSGPLAYER(playerid,COLOR_GREY," Vocк nгo й o motorista/piloto do veнculo");
return 1;
}
if(motor[playerid] == 0)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
motor[playerid] = 1;
SendClientMessage(playerid, 0xFFFFFFAA, "Veiculo {2F991A}Ligado, {FFFFFF}Digite /motor para desliga-lo");
}
else if(motor[playerid] == 1)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
motor[playerid] = 0;
SendClientMessage(playerid, 0xFFFFFFAA, "Veiculo {E31919}Desligado, {FFFFFF}Digite /motor para liga-lo");
}
}
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
if(motor[playerid] == 1){ sismotor(playerid); }
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, MotorOnOFF[i]);
motor[playerid] = 0;
}
return 1;
}
public sismotor(playerid)
{
if(motor[i] == 1)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Ligado");
motor[playerid] = 1; // ligado
}
else if(motor[i] == 0)
{
format(velopet5,sizeof(velopet5),"~r~~h~~h~~h~~h~Motor: ~w~Desligado");
motor[playerid] = 0; // desligado
}
TextDrawSetString(MotorOnOFF[i], velopet5);
return 1
}
pawn Код:
|