Textdraw rows - 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 rows (
/showthread.php?tid=581065)
Textdraw rows -
Lajko1 - 10.07.2015
Okay I have actually problems doing the following script:
I don't have any single clue how can I display rows in textdraws for example
/frisk (id) and it will show player's weapons in as textdraw but... for example can someone help with that?
Desert Eagle
M4
Ak-47
Shotgun
Re: Textdraw rows -
woot - 10.07.2015
https://sampwiki.blast.hk/wiki/Textdraw
Re: Textdraw rows -
Lajko1 - 10.07.2015
I know how to make text draw, but I don't know how to display player's weapon like that.
Re: Textdraw rows -
woot - 10.07.2015
What exactly don't you know? Use ~n~ for linebreaks in textdraws.
Show what you've tried so far.
Re: Textdraw rows -
Lajko1 - 10.07.2015
Well I did a little code and that's the problem why I'm asking cuz I can't figure out on my own, I tried on really simple way and it shows only one 1 weapon even I'm holding three of them so yeah what I want to do is, it will show me every weapon I have, and it should display in lines like:
Ak47
Eagle
Colt
Whatever
Code I tried ofc displays me only one weapon cuz I don't know how I can display this thing in textdraws it's much harder than SendClientMessage ^^
pawn Code:
CMD:frisk(playerid,params[])
{
new Player_Weapons[13];
new Player_Ammos[13];
new i;
for(i = 1;i <= 12;i++)
{
GetPlayerWeaponData(playerid,i,Player_Weapons[i],Player_Ammos[i]);
if(Player_Weapons[i] != 0)
{
new weaponName[256],string[256];
GetWeaponName(Player_Weapons[i],weaponName,255);
format(string,255,"Weapon Name: %s | Weapon Ammo's: %d.",weaponName,Player_Ammos[i]);
//SendClientMessage(playerid,0xFFFFFFAA,string);
TextDrawSetString(Weapons, string);
TextDrawShowForPlayer(playerid, Weapons);
}
}
return 1;
}
Re: Textdraw rows -
woot - 10.07.2015
You need to create a string and then use
strcat to append to that string in the loop.
Here's an example to get you started:
pawn Code:
new bigString[ 1024 ], tmpString[ 128 ], weaponName[ 32 ];
for(new i = 0; i <= 12; i++)
{
GetPlayerWeaponData(playerid, i, Player_Weapons[i], Player_Ammos[i]);
if(Player_Weapons[i] != 0)
{
GetWeaponName(Player_Weapons[i], weaponName, 32);
format(tmpString, sizeof(tmpString), "%s (Ammo: %d)~n~", weaponName, Player_Ammos[i]);
strcat(bigString, tmpString);
}
}
TextDrawSetString(Weapons, bigString);
TextDrawShowForPlayer(playerid, Weapons);
Re: Textdraw rows -
Lajko1 - 10.07.2015
You made my day, thank you a lot, if you have spare time can you actually explain me what in this code is making textdraws to display in line in exact way I wanted?
Rep+ for you