Problem vith this script -
AlexMedrea - 07.03.2012
So I made this script that stops your vehicle if car's healt is under 500.
Now the problem is that i want it to show a message that tells you to call for assistance.
I did it this way but it repeats SendClientMessage until you fix the vehicle.
Код:
#include <a_samp>
new engine, lights, alarm, doors, bonnet, boot, objective;
public OnPlayerUpdate(playerid)
{
new Float:health;
new veh;
veh = GetPlayerVehicleID(playerid);
if(health <500)
{
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, 0xCC0000FF, "{FFFFFF}Your car is broken. Type{00FFFF}/assistance. {FFFFFF}.");
}
if(health >500)
{
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}
return 1;
}
Re: Problem vith this script -
IstuntmanI - 07.03.2012
Try this:
Код:
#include <a_samp>
new engine, lights, alarm, doors, bonnet, boot, objective;
public OnPlayerUpdate(playerid)
{
new Float:health, veh = GetPlayerVehicleID(playerid);
if( health < 500 )
{
if( GetPVarInt( playerid, "MessageSent" ) == 0 )
{
GetVehicleParamsEx( veh, engine, lights, alarm, doors, bonnet, boot, objective );
SetVehicleParamsEx( veh, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective );
SendClientMessage( playerid, 0xCC0000FF, "{FFFFFF}Your car is broken. Type{00FFFF}/assistance. {FFFFFF}." );
SetPVarInt( playerid, "MessageSent", 1 );
}
}
else if( health > 500 )
{
GetVehicleParamsEx( veh, engine, lights, alarm, doors, bonnet, boot, objective );
SetVehicleParamsEx( veh, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective );
SetPVarInt( playerid, "MessageSent", 0 );
}
return 1;
}
Re: Problem vith this script -
AlexMedrea - 07.03.2012
Doesn't works. The Vehicle doesn't even stop
Re: Problem vith this script -
CAR - 07.03.2012
Try this, it's setting the player to warned if the message is sent. And if he has more health than 500 he's not warned anymore so he can be warned if he has lower health again
pawn Код:
#include <a_samp>
new engine, lights, alarm, doors, bonnet, boot, objective;
public OnPlayerUpdate(playerid)
{
new Float:health;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health <500 && !GetPVarInt(playerid, "warned"))
{
SetPVarInt(playerid, "warned", 1);
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, 0xCC0000FF, "{FFFFFF}Your car is broken. Type{00FFFF}/assistance.{FFFFFF}.");
}
if(health >500)
{
SetPVarInt(playerid, "warned", 0);
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}
return 1;
}
Re: Problem vith this script -
AlexMedrea - 07.03.2012
Thank you sir. Works great. The only problem now is that the message shows once when the player connects to the server