Message sending to id 0 only -
Tom1412 - 12.09.2013
hi guys,
Iv added a fuel system and i wanted it to send a message to the player saying you are out of fuel. but it only sends to player id 0 no matter who it is who runs out of fuel
pawn Код:
forward FuelUpdate(playerid);
public FuelUpdate(playerid)
{
for(new i = 1;i<MAX_VEHICLES;i++)
{
if(GetVehicleModel(i))
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1)
{
if(VehicleFuel[i] > 0) VehicleFuel[i]--;
else
{
SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, -1, "Engine Stalled.");
SendClientMessage(playerid, -1, "You are out of fuel.");
}
}
}
}
}
Re: Message sending to id 0 only -
zT KiNgKoNg - 12.09.2013
Look for "playerid" and replace that with "i"
Re: Message sending to id 0 only -
Tom1412 - 12.09.2013
I tried that but it made it not send any message, what i thought.
Re: Message sending to id 0 only -
zT KiNgKoNg - 12.09.2013
This might work, make sure you place it where your current SendClientMessage is.
Note: make sure you dont change " x " to i, but anything else will still work as-long as you replace x with the new letter
pawn Код:
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(GetPlayerVehicleID(x) == GetVehicleModel(i))
{
SendClientMessage(x, -1, "Engine Stalled.");
SendClientMessage(x, -1, "You are out of fuel.");
}
}
The reason that " i " didn't work when sending the message is that it is checking the MAX_VEHICLES and not players so it is basically trying to send the message to a vehicle, i just didn't look at the code correctly.
Re: Message sending to id 0 only -
Tom1412 - 12.09.2013
Still no luck, I anit getting any message.
Re: Message sending to id 0 only -
Jefff - 12.09.2013
pawn Код:
forward FuelUpdate();
public FuelUpdate()
{
static MaxP;
if(!MaxP)
MaxP = GetMaxPlayers();
for(new vehicleid = 1; vehicleid < MAX_VEHICLES; vehicleid++)
{
if(GetVehicleModel(vehicleid))
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine)
{
if(VehicleFuel[vehicleid] > 0) VehicleFuel[vehicleid]--;
else
{
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
for(new playerid=0; playerid != MaxP; playerid++)
if(IsPlayerConnected(playerid) && IsPlayerInVehicle(playerid,vehicleid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, -1, "Engine Stalled.");
SendClientMessage(playerid, -1, "You are out of fuel.");
break;
}
}
}
}
}
}