28.09.2012, 22:02
With some help, I got this far on showing the FPS of the player on a 3d label attached to them. The problem is that it always shows 0. Ive tried to change the "return 0" to something else and it while it does show something else, its not right.
Any help is appreciated.
Код:
//on top of script: new sFPS[16]; new Text3D:labelFPS[MAX_PLAYERS]; new DrunkL[MAX_PLAYERS]; new LDrunkL[MAX_PLAYERS]; new FPS[MAX_PLAYERS]; //this is in gamemodeinit: for(new i = 0; i < MAX_PLAYERS; i++) { labelFPS[i] = Create3DTextLabel("new", 0xFFFFFFFF, 30.0, 40.0, 50.0, 40.0, 0,0); } //this is in onplayerupdate: static time; if ((gettime() - time) > 5) //Updates each 5 seconds { format(sFPS, sizeof sFPS, "FPS: %i", GetPlayerFPS(playerid)); Update3DTextLabelText(labelFPS[playerid], 0xFFFFFFFF, sFPS); Attach3DTextLabelToPlayer(labelFPS[playerid], playerid, 0.0, 0.0, 0.7); time = gettime(); } //at bottom of script: stock GetPlayerFPS(playerid) { DrunkL[playerid] = GetPlayerDrunkLevel(playerid); if(DrunkL[playerid] < 100) { SetPlayerDrunkLevel(playerid, 2000); } else { if(LDrunkL[playerid] != DrunkL[playerid]) { FPS[playerid] = (LDrunkL[playerid] - DrunkL[playerid]); LDrunkL[playerid] = DrunkL[playerid]; if(FPS[playerid] > 0 && FPS[playerid] < 256) { return FPS[playerid] - 1; } } } return 0; }