OnPlayerUpdate Problem.
#1

So i use OnPlayerUpdate() to update a speedometer and a fuel indicator. But after some time it just stop working , The TextDraw just disapear and won't show again until i restart my server.

This is what i have on OnPlayerUpdate();

PHP код:
new Float:fPos[3],Float:Pos[4][2],Float:fSpeed;
    new 
vehicle GetPlayerVehicleID(playerid);
    new 
string2[64];
    if(
IsPlayerInAnyVehicle(playerid))
    {
        new 
Float:xFloat:yFloat:z;
        
GetPlayerPos(playeridxyz);
        
format(string2,sizeof(string2),"F:%d",CarFuel[vehicle]);
        
TextDrawSetString(FuelTextDraw[playerid], string2);
        new 
distance GetDistance1(xyzPlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
        
PlayerPos[0][playerid] = x;
        
PlayerPos[1][playerid] = y;
        
PlayerPos[2][playerid] = z;
        
PlayerTotalDistance[playerid] += distance;
        if (
PlayerTotalDistance[playerid] > DISTANCE) {
            
CarFuel[vehicle] -= FUEL_INCREMENT;
            
PlayerTotalDistance[playerid] = 0;
        }
        if (
CarFuel[vehicle] < 0) {
            
SendClientMessage(playerid, -1"You have been forced out your vehicle because you have no gas!");
            
RemovePlayerFromVehicle(playerid);
        }
        
    }
        if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
                
GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);
                
fSpeed floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) +
                 
floatpower(fPos[2], 2)) * 200;
                new 
Float:alpha 320 fSpeed;
                if(
alpha 60)
                    
alpha 60;
                for(new 
i4i++)
                {
                    
TextDrawHideForPlayer(playeridTextDrawsd[playerid][i]);
                    
TextDrawDestroy(TextDrawsd[playerid][i]);
                    
GetDotXY(548401Pos[i][0], Pos[i][1], alpha, (1) * 8);
                    
TextDrawsd[playerid][i] = TextDrawCreate(Pos[i][0], Pos[i][1], "~b~.");
                    
TextDrawLetterSize(TextDrawsd[playerid][i], 0.73, -2.60);
                    
TextDrawSetOutline(TextDrawsd[playerid][i], 0);
                    
TextDrawSetShadow(TextDrawsd[playerid][i], 1);
                    
TextDrawShowForPlayer(playeridTextDrawsd[playerid][i]);
                }
                
        }
        return 
1
Reply
#2

don't destroy and create every time but use TextDrawSetString
https://sampwiki.blast.hk/wiki/TextDrawSetString
Reply
#3

Ok, i'l try this , but on fuel i don't destroy it .. and still disapear ... this usualy happends after like an hour after the server starts ..

Edit: and that "." i need to destroy it and create it again because i need it to be on another position .. i don't know how else to do this. Whit SetString it only modify the string but not the position.
Reply
#4

Can someone help? everything i put in onplayerupdate stop working after a few hours ... i tried making another speedometer and that stop working to . Please some help.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)