19.11.2009, 06:33
its because you didnt define the string for individual players, you defined it for all players together. if you use the string variable as global then you should visit http://forum.sa-mp.com/index.php?topic=134164.0 else do the string variable as local inside the Box function
SOLUTION
TRY IT :P I did not test it but i think its alright UPDATED!!!! Should work now with no changes made
SOLUTION
Код:
#include <a_samp> #include <a_npc> new Text:InfoBox[MAX_PLAYERS]; new ITimer[MAX_PLAYERS]; new IBoxString[MAX_PLAYERS][128]; // as we use it as global, we don't want any conflicts with healths of other players new Float:VHealth[MAX_VEHICLES]; forward UInfoBox(playerid); // defined player id removes need of variable PID[]; public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Vehicle Health Script "); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { KillTimer(ITimer[playerid]); TextDrawHideForPlayer(playerid, InfoBox[playerid]); return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) { InfoBox[playerid] = TextDrawCreate(200.0, 360.0, " "); TextDrawUseBox(InfoBox[playerid],0); TextDrawTextSize(InfoBox[playerid], 440, 410); TextDrawBoxColor(InfoBox[playerid],0x00000066); TextDrawSetOutline(InfoBox[playerid],1); TextDrawLetterSize(InfoBox[playerid],0.5,1.2); TextDrawSetShadow(InfoBox[playerid],0); ITimer[playerid] = SetTimerEx("UInfoBox", 250, 1,"i",playerid); // changed the timer to 250, no need top be faster unless u use it for speed detection } else { KillTimer(ITimer[playerid]); TextDrawHideForPlayer(playerid, InfoBox[playerid]); } return 1; } public UInfoBox(playerid) { GetVehicleHealth(GetPlayerVehicleID(playerid), VHealth[GetPlayerVehicleID(playerid)]); format(IBoxString[playerid], sizeof(IBoxString[])-1, "~r~Vehicle Health: ~y~%.1f~n~~r~", VHealth[GetPlayerVehicleID(playerid)]/10); TextDrawHideForPlayer(playerid, InfoBox[playerid]); TextDrawSetString(InfoBox[playerid], IBoxString[playerid]); TextDrawShowForPlayer(playerid, InfoBox[playerid]); }