forward sismotor(vehicleid);
public sismotor(vehicleid)
{
new velopet5[128];
for (new i=0; i<MAX_PLAYERS; i++)
if(GetPlayerState(i))
{
if(motor[i] == 1)
{
format(velopet5,sizeof(velopet5),"~d~~w~~h~Motor~p~: ~p~ligado");
motor[i] = 1; // ligado
}
else if(motor[i] == 0)
{
format(velopet5,sizeof(velopet5),"~d~~w~~h~Motor~p~: ~p~Desligado");
motor[i] = 0; // desligado
}
TextDrawSetString(MotorOnOFF[i], velopet5);
}
return 1;
}
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[playerid]);
motor[playerid] = 0;
}
SetTimer("sismotor", 500, 1);
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;
}
// GetVehicleParams...
for(new a; a < MAX_PLAYERS; ++a)
{
if(IsPlayerConnected(a) && GetPlayerVehicleID(playerid) == GetPlayerVehicleID(a))
PlayerTextDrawSetString(a,texto[a],engine == 1 ? ("Motor: ligado") : ("Motor: desligado"));
}
Quando for ligar/desligar o motor sу passar um loop por todos os players, e ver quem estб no mesmo veнculo.
pawn Код:
|
Cara nгo sei muito isso de loop, Tem como explicar detalhadamente?
|
e so usar aquele code que ele passou
mas acho um pouco estranho mostrar o velocimetro ao passageiro tbm, acho que isso e so quem vai a dirigir que deveria ver, mas vc que sabe. |
for(new a; a < MAX_PLAYERS; ++a)
{
if(IsPlayerConnected(a) && GetPlayerVehicleID(playerid) == GetPlayerVehicleID(a))
PlayerTextDrawSetString(a,texto[a],engine == 1 ? ("Motor: ligado") : ("Motor: desligado"));
}
forward sismotor(vehicleid);
public sismotor(vehicleid)
{
for(new a; a < MAX_PLAYERS; ++a)
{
if(IsPlayerConnected(a) && GetPlayerVehicleID(playerid) == GetPlayerVehicleID(a))
PlayerTextDrawSetString(MotorOnOFF[a],texto[a],motor[a] == 1 ? ("Motor: ligado") : ("Motor: desligado"));
}
return 1;
}
se nao tou em erro e aqui
pawn Код:
|
PlayerTextDrawSetString(MotorOnOFF[a], motor[a] == 1 ? ("Motor: ligado") : ("Motor: desligado"));
forward sismotor(vehicleid); public sismotor(vehicleid)
{
for(new i, e = GetMaxPlayers(); (i ^ e); ++i){
if((!(GetPlayerState(i) ^ 3) & !(GetPlayerVehicle(i) ^ vehicleid)) TextDrawSetString(MotorOnOFF[i], motor[i] ? ("~d~~w~~h~Motor~p~: ~p~ligado") : ("~d~~w~~h~Motor~p~: ~p~Desligado");
}
return 1;
}