Textdraw question - 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)
+--- Thread: Textdraw question (
/showthread.php?tid=657568)
Textdraw question -
KinderClans - 10.08.2018
Hello, i have a textdraw which shows "Available Jobs" text. Since i have 8 jobs, i don't wanna create 8 textdraws. It's possible, using string, show this 8 jobs in a single textdraw?
Example:
Available jobs:
Robber
Rapist
Medic
Etc. Etc.
Currently i have this (created now) which is supposed to show jobs names:
pawn Код:
new stock JobNames[][] =
{
"Robber", "Rapist", "Medic"
};
How to pass it in a string to show it in the textdraw?
Thanks
Re: Textdraw question -
GRiMMREAPER - 10.08.2018
This should do the job:
pawn Код:
new jobsText[50]; // Increase/decrease the size if necessary.
new JobNames[][] =
{
"Robber", "Rapist", "Medic"
};
pawn Код:
// Wherever you create your textdraws.
for(new i = 0; i < sizeof JobNames; i++) {
strcat(jobsText, JobNames[0][i]);
if(i != sizeof(JobNames) - 1) { // Preventing a new line from being added in the last line.
strcat(jobsText, "~n~");
}
}
TextDrawSetString(YOUR_TEXTDRAW, jobsText);
Re: Textdraw question -
NaS - 10.08.2018
Quote:
Originally Posted by GRiMMREAPER
This should do the job:
pawn Код:
new jobsText[50]; // Increase/decrease the size if necessary. new JobNames[][] = { "Robber", "Rapist", "Medic" };
pawn Код:
// Wherever you create your textdraws. for(new i = 0; i < sizeof JobNames; i++) { strcat(jobsText, JobNames[0][i]); if(i != sizeof JobNames) { // Preventing a new line from being added in the last line. strcat(jobsText, "~"); } }
TextDrawSetString(YOUR_TEXTDRAW, jobsText);
|
The "~" should be "~n~". Furthermore i will never reach the size of the array. Its max. value will be sizeof(JobNames) - 1.
Re: Textdraw question -
GRiMMREAPER - 10.08.2018
Quote:
Originally Posted by NaS
The "~" should be "~n~". Furthermore i will never reach the size of the array. Its max. value will be sizeof(JobNames) - 1.
|
Thanks for noticing the typo.
Re: Textdraw question -
KinderClans - 10.08.2018
Thank you for your help but this is what i get:
Why?
Re: Textdraw question -
GRiMMREAPER - 10.08.2018
My bad. The first strcat statement should be
strcat(jobsText, JobNames[i]); — I got confused. With that being said, there shouldn't be any other bugs.
Re: Textdraw question -
BigETI - 10.08.2018
I didn't know that being a rapist is a job.
Re: Textdraw question -
Deadpoop - 10.08.2018
Quote:
Originally Posted by BigETI
I didn't know that being a rapist is a job.
|
Isnt that your job?
Re: Textdraw question -
KinderClans - 10.08.2018
Quote:
Originally Posted by GRiMMREAPER
My bad. The first strcat statement should be strcat(jobsText, JobNames[i]); — I got confused. With that being said, there shouldn't be any other bugs.
|
what
Re: Textdraw question -
GRiMMREAPER - 10.08.2018
Quote:
Originally Posted by KinderClans
what
|
Check the first comment.
EDIT: Didn't see the earlier replies, sorry.