SA-MP Forums Archive
Wanted lvl updating, but not textdraw - 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: Wanted lvl updating, but not textdraw (/showthread.php?tid=655437)



Wanted lvl updating, but not textdraw - div - 21.06.2018

heres the code

Код:
new PlayerText:WLvlTD[MAX_PLAYERS];
Код:
if(pInfo[playerid][pWanted] >= 6)
	{
    new lvl[9];
	format(lvl, sizeof(lvl), "%d", pInfo[playerid][pWanted]);
	WLvlTD[playerid] = CreatePlayerTextDraw(playerid, 548.800109, 123.297790, lvl); //for wanted level displaying
	PlayerTextDrawLetterSize(playerid, WLvlTD[playerid], 0.396799, 1.838933);
	PlayerTextDrawTextSize(playerid, WLvlTD[playerid], -7.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, WLvlTD[playerid], 1);
	PlayerTextDrawColor(playerid, WLvlTD[playerid], -5963521);
	PlayerTextDrawSetShadow(playerid, WLvlTD[playerid], -1);
	PlayerTextDrawSetOutline(playerid, WLvlTD[playerid], 2);
	PlayerTextDrawBackgroundColor(playerid, WLvlTD[playerid], 255);
	PlayerTextDrawFont(playerid, WLvlTD[playerid], 2);
	PlayerTextDrawSetProportional(playerid, WLvlTD[playerid], 1);
	
	wStars[playerid] = CreatePlayerTextDraw(playerid, 578.401123, 123.297912, "[]    []");
	PlayerTextDrawLetterSize(playerid, wStars[playerid], 0.355600, 2.048001);
	PlayerTextDrawTextSize(playerid, wStars[playerid], -225.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, wStars[playerid], 3);
	PlayerTextDrawColor(playerid, wStars[playerid], -5963521);
	PlayerTextDrawSetShadow(playerid, wStars[playerid], 0);
	PlayerTextDrawBackgroundColor(playerid, wStars[playerid], 255);
	PlayerTextDrawFont(playerid, wStars[playerid], 0);
	PlayerTextDrawSetProportional(playerid, wStars[playerid], 1);

	wLvlStars[playerid] = CreatePlayerTextDraw(playerid, 492.801116, 99.302291, "[][][][][][]");
	PlayerTextDrawLetterSize(playerid, wLvlStars[playerid], 0.309600, 2.192178);
	PlayerTextDrawTextSize(playerid, wLvlStars[playerid], -111.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, wLvlStars[playerid], 1);
	PlayerTextDrawColor(playerid, wLvlStars[playerid], -5963521);
	PlayerTextDrawSetShadow(playerid, wLvlStars[playerid], 1);
	PlayerTextDrawBackgroundColor(playerid, wLvlStars[playerid], 255);
	PlayerTextDrawFont(playerid, wLvlStars[playerid], 0);
	PlayerTextDrawSetProportional(playerid, wLvlStars[playerid], 1);
	}

Код:
if(GetPVarInt(playerid,"Wanted") != pInfo[playerid][pWanted])
    {
        new wlvl[9];
		format(wlvl, 9, "%d", pInfo[playerid][pWanted]);
        PlayerTextDrawSetString(playerid, WLvlTD[playerid], wlvl);
        SetPVarInt(playerid,"Wanted", pInfo[playerid][pWanted]);
		new query[128], name[24];
		GetPlayerName(playerid, name, 24);
		format(query, sizeof(query), "UPDATE `playerdata` SET `wanted` = '%d' WHERE `username` = '%s'", pInfo[playerid][pWanted], name);
		mysql_tquery(dbHandle, query);
    }



Re: Wanted lvl updating, but not textdraw - div - 21.06.2018

EDIT: It shows when i RELOG, but not when i set it through a command..


Re: Wanted lvl updating, but not textdraw - andrejc999 - 21.06.2018

Why are you creating new textdraws everytime a player has more than 6 wls? Just create them when a player connects and hide them, so when a player has more than 6 wls show them to the player and that's all.


Re: Wanted lvl updating, but not textdraw - div - 21.06.2018

lemme try and tell ya


Re: Wanted lvl updating, but not textdraw - div - 21.06.2018

That's ok, but what should i do for updating the WANTED level?


It doesn't update and show the textdraws..


Re: Wanted lvl updating, but not textdraw - div - 21.06.2018

help pls


Re: Wanted lvl updating, but not textdraw - Sew_Sumi - 21.06.2018

24 hour bumps only. Otherwise all you're doing is spamming.

You don't need to keep recreating the textdraws.

You create the textdraws when the player connects, and hide them, and then when their wanted level goes up, you start revealing them, or changing the textdraw contents themselves.


Re: Wanted lvl updating, but not textdraw - Revy - 21.06.2018

As mentioned above by Sew, create the PlayerTextDraw's under "OnPlayerConnect" and then just hide them, once their wanted level goes up you can use PlayerTextDrawSetString, and PlayerTextDrawShow or PlayerTextDrawHide depending if you would like to display or hide them. Because re-creating the same TextDraw's all the time is not the correct way of doing this, you can simply create them one time.


Re: Wanted lvl updating, but not textdraw - Private200 - 21.06.2018

I thought of making look a bit better. What about updating the textdraw for every wanted star he gets from 1 to 6 and then stop updating the textdraw? So the textdraw will start showing stars from 1, 2, 3, 4, 5, 6 and then stick to 6. If the player wanted level gets reduced, stars will also get reduced. If his wanted level disappears, the textdraw will also become empty.

PHP код:
if(GetPVarInt(playerid,"Wanted") != pInfo[playerid][pWanted])
{
    new 
wlvl[9];
    
format(wlvl9"%d"pInfo[playerid][pWanted]);
    
PlayerTextDrawSetString(playeridWLvlTD[playerid], wlvl);
    
SetPVarInt(playerid,"Wanted"pInfo[playerid][pWanted]);
    new 
query[128], name[24];
    
GetPlayerName(playeridname24);
    
format(querysizeof(query), "UPDATE `playerdata` SET `wanted` = '%d' WHERE `username` = '%s'"pInfo[playerid][pWanted], name);
    
mysql_tquery(dbHandlequery);
    
    new 
starCount 0genTextStr[30];
    if(
pInfo[playerid][pWanted] > 0) {
        
format(genTextStrsizeof genTextStr"");
        for(new 
0pInfo[playerid][pWanted]; i++) {
            
starCount++;
            if(
starCount == 6) { 
                break;
            }
            else {
                
strcat(genTextStr"[]"sizeof genTextStr);
            }
        }
        
PlayerTextDrawSetString(playeridwLvlStars[playerid], genTextStr);
    }
    
    if(
pInfo[playerid][pWanted] == 0) {
        
PlayerTextDrawSetString(playeridwLvlStars[playerid], "");
    }

Test this out and tell me if it works.

Edit: just make sure you show the textdraw in OnPlayerConnect

PHP код:
PlayerTextDrawShow(wLvlStars[playerid]); 



Re: Wanted lvl updating, but not textdraw - div - 21.06.2018

It's not going to be of any use, because the starting wanted level is going to be 6.. :/


And i did try it, It did NOT update the WANTED level TEXTDRAW..

I appreciate your valuable time..