Textdraw help
#1

Is it possible to make a textdraw list and add stuff to the list with a command? For example a phonebook and add numbers with a comand like "/addnumber [number]" and then when you use "/phonebook" it will show the list.
Reply
#2

Yes, simply use the function strcat and then have a string which you keep adding to using "/addnumber [number]" or through any callback you want, then you can just display that string in the textdraw.
Reply
#3

Can you please give me an example, coz i don't really understand.
Reply
#4

Okay here is a simple example using zcmd for the command:

pawn Код:
new numberdraw[500];

CMD:addnumber(playerid, params[])
{
    if(!params[0]) return SendClientMessage(playerid, color, "Usage: /addnumber [number]");
    strcat(numberdraw, params);
    SendClientMessage(playerid, color, "The number has been added");
    return 1;
}
Then you can simply display the string using a textdraw as usual, does that help?

The only problem is that you'll need quite a big array to handle all of the data.
Reply
#5

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Okay here is a simple example using zcmd for the command:

pawn Код:
new numberdraw[500];

CMD:addnumber(playerid, params[])
{
    if(!params[0]) return SendClientMessage(playerid, color, "Usage: /addnumber [number]");
    strcat(numberdraw, params);
    SendClientMessage(playerid, color, "The number has been added");
    return 1;
}
Then you can simply display the string using a textdraw as usual, does that help?

The only problem is that you'll need quite a big array to handle all of the data.
I got the command part, but i don't get how to display the textdraw with it.
Reply
#6

Create your textdraw as usual and then by using TextDrawSetString you can edit it, just like you always do. Except this time put the array into it, for example:

pawn Код:
TextDrawSetString(yourtext, numberdraw);
Doesn't that make sense? There's plenty of examples available on the wiki, like the one I linked.
Reply
#7

Well yes, it kinda does. Thanks for the help
Reply
#8

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Okay here is a simple example using zcmd for the command:

pawn Код:
new numberdraw[500];

CMD:addnumber(playerid, params[])
{
    if(!params[0]) return SendClientMessage(playerid, color, "Usage: /addnumber [number]");
    strcat(numberdraw, params);
    SendClientMessage(playerid, color, "The number has been added");
    return 1;
}
Then you can simply display the string using a textdraw as usual, does that help?

The only problem is that you'll need quite a big array to handle all of the data.
The params will never be null with ZCMD. Use isnull instead.
Reply
#9

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
The params will never be null with ZCMD. Use isnull instead.
I see, I have never actually used ZCMD really in practice so I assumed that it would, it's bizzare that it isn't. I'm guessing there's a reason for it though. Although your sentence is quite contradictive!

"dont check if its null use isnull to check if its null"
Reply
#10

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
I see, I have never actually used ZCMD really in practice so I assumed that it would, it's bizzare that it isn't. I'm guessing there's a reason for it though. Although your sentence is quite contradictive!

"dont check if its null use isnull to check if its null"
It seems to be because if you use Null as a param for CallRemoteFunction / CallLocalFunction it just crashes the sa-mp server. So you must use something in the param so that it doesn't cause crashes.

"The params will never be null with ZCMD. Use isnull instead."
- Never null
- Use function isnull :P.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)