Wanted lvl updating, but not textdraw

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);

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

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.

lemme try and tell ya

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

It doesn't update and show the textdraws..

help pls

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.

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.

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])
PlayerTextDrawSetString(playeridWLvlTD[playerid], wlvl);
query[128], name[24];
format(querysizeof(query), "UPDATE `playerdata` SET `wanted` = '%d' WHERE `username` = '%s'"pInfo[playerid][pWanted], name);
starCount 0genTextStr[30];
pInfo[playerid][pWanted] > 0) {
format(genTextStrsizeof genTextStr"");
0pInfo[playerid][pWanted]; i++) {
starCount == 6) { 
            else {
strcat(genTextStr"[]"sizeof genTextStr);
PlayerTextDrawSetString(playeridwLvlStars[playerid], genTextStr);
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 код:

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..

Forum Jump:

Users browsing this thread: 1 Guest(s)