[HELP] Seatbelts - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Seatbelts (
/showthread.php?tid=289465)
[HELP] Seatbelts -
Dirkon - 11.10.2011
Hello!
I made little seatbelt system, but it only affects the driver. Here's the script:
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
if(Seatbelt[playerid] == 0)
{
GetVehicleHealth(vehicleid, vehhealthup[playerid]);
new Float:health;
GetPlayerHealth(playerid,health);
health = health - ((vehhealth[playerid] - vehhealthup[playerid])/10);
SetPlayerHealth(playerid, health);
GetVehicleHealth(vehicleid, vehhealth[playerid]);
}
else if(Seatbelt[playerid] == 1)
{
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* Seatbelt saves (( %s ))", str);
ProxDetector(10.0, playerid, str, COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK);
}
return 1;
}
How could I make it work for all players sitting in the car without overloading server a lot? Any ideas?
Re: [HELP] Seatbelts -
IstuntmanI - 11.10.2011
Only with a loop:
Код:
public OnVehicleDamageStatusUpdate( vehicleid, playerid )
{
new Float:health, str[ 128 ];
for( new i; i < MAX_PLAYERS; i ++ )
{
if( !IsPlayerInVehicle( i, vehicleid ) )
continue;
switch( Seatbelt[ playerid ] )
{
case 0:
{
GetVehicleHealth( vehicleid, vehhealthup[ playerid ] );
GetPlayerHealth( playerid, health );
health = health - ( ( vehhealth[ playerid ] - vehhealthup[ playerid ] ) / 10 );
SetPlayerHealth( playerid, health );
GetVehicleHealth( vehicleid, vehhealth[ playerid ] );
}
case 1:
{
GetPlayerName( playerid, str, 128 );
format( str, 128, "* Seatbelt saves (( %s ))", str );
ProxDetector( 10.0, playerid, str, COLOR_PINK, COLOR_PINK, COLOR_PINK, COLOR_PINK, COLOR_PINK );
}
}
}
return 1;
}