SA-MP Forums Archive
Textdraw help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Textdraw help (/showthread.php?tid=277048)



Textdraw help - idgl3on - 16.08.2011

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.


Re: Textdraw help - JaTochNietDan - 16.08.2011

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.


Re: Textdraw help - idgl3on - 16.08.2011

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


Re: Textdraw help - JaTochNietDan - 16.08.2011

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.


Re: Textdraw help - idgl3on - 16.08.2011

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.


Re: Textdraw help - JaTochNietDan - 16.08.2011

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.


Re: Textdraw help - idgl3on - 16.08.2011

Well yes, it kinda does. Thanks for the help


Re: Textdraw help - [HiC]TheKiller - 16.08.2011

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.


Re: Textdraw help - JaTochNietDan - 16.08.2011

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"


Re: Textdraw help - [HiC]TheKiller - 16.08.2011

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.