TextDraw doesn't dissapear
#1

pawn Код:
if(KillSpree[killerid] >=3)
    {
        TextDrawHideForAll(Textdraw0);
        KillTimer(aaa);
        aaa = SetTimer("textdrawkiller", 5000, false);
        TextDrawShowForAll(Textdraw0);
        return 1;
    }
    if(KillSpree[playerid] >=3)
    {
        new string[128];
        TextDrawHideForAll(Textdraw0);
        KillTimer(aaa);
        aaa = SetTimer("textdrawkiller", 5000, false);
        TextDrawShowForAll(Textdraw0);
        format(string, sizeof(string), "~r~%s ~y~- Killing Spree ended", kname, KillSpree[killerid]);
        TextDrawSetString(Textdraw0, string);
        return 1;
    }
    return 1;
}
I got that code, but when a player dies the Textdraw doesn't dissapears and stays there, please help me
Reply
#2

Can I see your function textdrawkiller?
Reply
#3

use SetTimerEx
Reply
#4

textdrawkiller has no function o.o
Reply
#5

1. 'aaa' and 'Textdraw0' are TERRIBLE variable names.
2. SetTimerEx should be used if an argument (playerid) needs to be passed.
3. Why do you hide the TD then show it again?
4. You're killing a timer without knowing if it's running. If the ID is unassigned you will kill timer ID 0, which is usually your 'main' script timer.
5. You don't need a 128-char array for a string that'll only ever be 52 (28+24) characters long.
6. You don't check whether 'killerid' is a valid player ID (if(killerid != INVALID_PLAYER_ID))before taking action on it (which can cause array index out of bound issues which will crash your script).
7. You shouldn't return anything like that. If you put code under it it'll never be called. You'll come back later and post a new topic here saying 'why him not werks?'.
8. You shouldn't really use a timer. You should destroy/hide it when the player re-spawns (OnPlayerSpawn)
9. Why are you showing/hiding the textdraw to ALL players, if it's only meant to be informing one player about their killing spree..?
10. The spacing in your if() statements could be better. It's not readable at a glance: if(KillSpree[killerid] >=3) should be if(KillSpree[killerid] >= 3)

Biggest list of problems I've ever made for such short code!

EDIT: Regarding point 9 - I guess I didn't read in to the code TOO much. Looks like you're announcing it to the entire server.
Reply
#6

can someone send me how it should be the code, cauz i can't understand
Reply
#7

Okay, I misunderstood SOME parts of this. But most of my points are still valid.
Reply
#8

I need a code pls :/ i don't understand anything u say :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)