26.07.2012, 14:14
(
Последний раз редактировалось Misiur; 26.07.2012 в 14:51.
Причина: Solved
)
Hello, this is my code
1. TextDrawCreate for first usage returns handle 0, which causes conditional if(Texts[i]) to be evaluated as true, even though textdraw exists. How can I check if textdraw indeed exists?
2. After TextDrawDestroy, the Texts[i] is not emptied. Text is strong tag and I can't simply use Texts[i] = 0; or something. How can I remove this specific array element?
If there aren't any answers I think I'll go with 2 dimensional array, holding state and handle separately.
Edit:
After digging some more I found the Text:INVALID_TEXT_DRAW constant. It's useful.
pawn Код:
new Text:Texts[4];
CMD:text(playerid, params[]) {
new input[256], i = 0;
if(sscanf(params, "s[255]", input)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /text <msg>");
for(i = 0; i < 4; i++) {
if(!Texts[i]) break;
}
if(i <= 4) {
Texts[i] = TextDrawCreate(200, 30+(40*i), input);
TextDrawAlignment(Texts[i], 3);
TextDrawShowForAll(Texts[i]);
}
return true;
}
CMD:remtext(playerid, params[]) {
new i;
if(sscanf(params, "i", i)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /remtext <id>");
if(Texts[i]) TextDrawDestroy(Texts[i]);
return 1;
}
2. After TextDrawDestroy, the Texts[i] is not emptied. Text is strong tag and I can't simply use Texts[i] = 0; or something. How can I remove this specific array element?
If there aren't any answers I think I'll go with 2 dimensional array, holding state and handle separately.
Edit:
After digging some more I found the Text:INVALID_TEXT_DRAW constant. It's useful.