SA-MP Forums Archive
[Include] rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! (/showthread.php?tid=421863)

Pages: 1 2


rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! (Version 0.2) - RajatPawar - 11.03.2013

Hello guys.
This is an include of mine.
Use it to whatever needs you have.
NOTE: Please use ~n~ before the 33rd character of any sentence, if not, it will go outta the box.
Am working on adding a #if statement to make it easier for you guys.



Stock functions:
pawn Code:
native CreateTDboxForPlayer(playerid, title[], titlecolor, string[]);
native ShowTDboxToPlayer(playerid, boxid);
native HideTDboxForPlayer(playerid, boxid);
native ResetTDboxes();
native IsPlayerViewingTDBox(playerid, boxid);
native IsPlayerViewingAnyTDBox(playerid);
Example scripts:
pawn Code:
CMD:help(playerid)
{
new Te = CreateTDboxForPlayer(playerid, "Help me!", -1, "~w~1. ~y~Buy potatoes~n~~w~2.~y~ Buy some ~r~crazy ~g~shit~n~~w~3.~y~ Some random option~n~4. Exit");
ShowTDboxToPlayer(playerid, Te);
return 1;
}
SS:


Examples/How to:

Each menu created is assigned an ID, you must use it to show it to a player. For example:
pawn Code:
new h_box =CreateTDBoxForPlayer(playerid, "Help! " , MY_COLOR_DEFINE, "My help~n~Bla Bla");
Then:
pawn Code:
ShowTDBoxToPlayer(playerid, h_box);
To say, cancel it on player click:
pawn Code:
public OnPlayerKeyStateChange(..)
{
   if(newkeys & KEY_FIRE)
   {
        if(IsPlayerViewingTDBox(playerid, h_box))
        {
            HideTDboxForPlayer(playerid, h_box);
        }  
   }
}
To reset all IDS, just use ResetTDs. (Of no use, to be honest, since this doesn't save IDs)
To check if he's viewing any TD Box - IsPlayerViewingAnyTDBox(playerid) !

Thanks. That's it.
I used y_hooks for this.
To use it, just do:
pawn Code:
#include <rInfoBox>
Credits:
****** - y_hooks
Sinner - for his awesome bug solving skills
iPleoMax - for his ultra superb TD editor
ZCMD - for his zcmd

You all !

Download:
Clicky here

FAQ:
1) I can't go to the next line? Even though I used ~n~?
Ans: You must use ~n~ connecting two letters, for example:
CORRECT:
pawn Code:
something~n~something
WRONG:
pawn Code:
something ~n~ something
Extra:
Some stocks you can make on your own
pawn Code:
stock ShowTDBoxToAll(playerid, boxid)
{
  for( new i; i < MAX_PLAYERS; i++)
{
   ShowTDBoxToPlayer(i, boxid)
}
return 1;
}



Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - greentarch - 11.03.2013

Very nice!
So, if I want to see if a player has entered a selection ( 1, 2, 3, etc ), it's like this, right?
pawn Code:
public OnPlayerText( playerid, text[ ] )
{
    if ( IsPlayerViewingTDBox( playerid, test_box ) )
    {
        if ( strval( text ) == 4 ) // Close box!
            return HideTDboxForPlayer( playerid, test_box ), 0; // Hides the box and return 0, so the message will not be send!
    }

    return 1;
}
Correct me if I'm wrong

I'm going to try to make something with this :3

---
Btw,
on your native list :
pawn Code:
native HideTDboxForPlayer(playerid, boxid);
but in your example ( not the cmd! )
pawn Code:
HideTDBoxForPlayer(playerid, h_box);
( notice that the 'b' at "Box" is capitalized )
I think PAWN is case-sensitive!


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - RajatPawar - 11.03.2013

Quote:
Originally Posted by greentarch
View Post
Very nice!
So, if I want to see if a player has entered a selection ( 1, 2, 3, etc ), it's like this, right?
pawn Code:
public OnPlayerText( playerid, text[ ] )
{
    if ( IsPlayerViewingTDBox( playerid, test_box ) )
    {
        if ( strval( text ) == 4 ) // Close box!
            return HideTDboxForPlayer( playerid, test_box ), 0; // Hides the box and return 0, so the message will not be send!
    }

    return 1;
}
Correct me if I'm wrong

I'm going to try to make something with this :3

---
Btw,
on your native list :
pawn Code:
native HideTDboxForPlayer(playerid, boxid);
but in your example ( not the cmd! )
pawn Code:
HideTDBoxForPlayer(playerid, h_box);
( notice that the 'b' at "Box" is capitalized )
I think PAWN is case-sensitive!
Oh yes, my mistake, it's "b" ! Thanks
And yeah, that was correct:
pawn Code:
public OnPlayerText( playerid, text[ ] )
{
    if ( IsPlayerViewingTDBox( playerid, test_box ) )
    {
        if ( strval( text ) == 4 ) // Close box!
            return HideTDboxForPlayer( playerid, test_box ), return 0;
        // Do whatever you want here!
    }

    return 1;
}
Also, updated with one more example!


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - greentarch - 11.03.2013

I seem to get some warnings at this line :
pawn Code:
stock IsPlayerViewingTDBox(playerid, boxid)
{
    if(InfoBox[boxid][mShown] = true) return 1;
    else return 0;
}
The warnings are :
pawn Code:
C:\Users\Marcho\Documents\[ SA-MP Server ]\pawno\include\rInfoBox.inc(122) : warning 211: possibly unintended assignment
C:\Users\Marcho\Documents\[ SA-MP Server ]\pawno\include\rInfoBox.inc(120) : warning 203: symbol is never used: "playerid"
I'm trying to make a food shop, can you help me with these warnings?

( Maybe create a var if the player is viewing a box, e.g : )
pawn Code:
new
   viewingBox[ MAX_PLAYERS ];

// showtdboxtoplayer
viewingBox[ playerid ] = boxid;

// isplayerviewingtdbox
if ( viewingBox[ playerid ] == boxid )
    return true;
return false;
Something like that?


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - RajatPawar - 11.03.2013

Oh fack, I forgot that one.
It should have been:
pawn Code:
stock IsPlayerViewingTDBox(playerid, boxid)
{
    if(InfoBox[boxid][mShown] == true) return 1;
    else return 0;
}
UPDATED!
You should be able to make it now.


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - greentarch - 11.03.2013

Uhh, it still shows up like this :
pawn Code:
C:\Users\Marcho\Documents\[ SA-MP Server ]\pawno\include\rInfoBox.inc(122) : warning 211: possibly unintended assignment
C:\Users\Marcho\Documents\[ SA-MP Server ]\pawno\include\rInfoBox.inc(120) : warning 203: symbol is never used: "playerid"
( perhaps you still used your old download link )

or maybe like this :
pawn Code:
new
   viewingBox[ MAX_PLAYERS ];

// showtdboxtoplayer
viewingBox[ playerid ] = boxid;

// isplayerviewingtdbox
if ( viewingBox[ playerid ] == boxid )
    return true;
return false;



Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - RajatPawar - 11.03.2013

Updated: New download link.


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - greentarch - 11.03.2013

Cheers, now it compiled successfully.

Problem below is fixed!

But, I seem to have some problems with running my filterscript. samp-server.exe always closes if I add my filterscript at server.cfg. Without the filterscript samp-server.exe does run normally.

And, I do have YSI at my pawno/includes.

---

Here's my script - http://pastebin.com/raw.php?i=V28tYdVu
and my server log :
Code:
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3x, ©2005-2013 SA-MP Team

[16:43:52] 
[16:43:52] Server Plugins
[16:43:52] --------------
[16:43:52]  Loading plugin: whirlpool
[16:43:52]  
[16:43:52]  ==================
[16:43:52]  
[16:43:52]   Whirlpool loaded
[16:43:52]  
[16:43:52]  ==================
[16:43:52]  
[16:43:52]   Loaded.
[16:43:52]  Loading plugin: streamer
[16:43:52] 

*** Streamer Plugin v2.6.1 by Incognito loaded ***

[16:43:52]   Loaded.
[16:43:52]  Loading plugin: sscanf
[16:43:52] 

[16:43:52]  ===============================

[16:43:52]       sscanf plugin loaded.     

[16:43:52]          Version:  2.8.1        

[16:43:52]    © 2012 Alex "******" Cole  

[16:43:52]  ===============================

[16:43:52]   Loaded.
[16:43:52]  Loaded 3 plugins.

[16:43:52] 
[16:43:52] Filterscripts
[16:43:52] ---------------
[16:43:52]   Loading filterscript 'foodShop.amx'...
[16:43:52]  
[16:43:52]  
[16:43:52]  
[16:43:52]  ======================================= 
[16:43:52]  |                                     | 
[16:43:52]  |        YSI version 1.06.0002        | 
[16:43:52]  |        By Alex "******" Cole        | 
[16:43:52]  |                                     | 
[16:43:52]  ======================================= 
[16:43:52]  
[16:43:52]  
[16:43:52]
Can you help me with it?

EDIT: I have seemed to fixed it. I edited your include a bit


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - RajatPawar - 11.03.2013

This include uses y_hooks !
pawn Code:
#include <YSI\y_hooks>
I am not sure if the user has to include it, but try doing that. I see no other problem !
Also, do post your server.cfg.


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - greentarch - 11.03.2013

I've fixed the problem above with editing the include. Now my script can run
Cheers!


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - RajatPawar - 11.03.2013

Can you PM me the 'fix' you have made? And the line number, so this doesn't arise for other users?


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - RyanDam - 11.03.2013

NIce script, can I make seperate lines by isng /n as normally?


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - greentarch - 11.03.2013

You can add a new line with
pawn Код:
~n~
See the FAQ for more info.
It's like
pawn Код:
1. Hello~n~2. Hi~n~3. How are you?
Will give you something like
pawn Код:
1. Hello
2. Hi
3. How are you?
( not with \n )


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - RajatPawar - 11.03.2013

Quote:
Originally Posted by greentarch
Посмотреть сообщение
You can add a new line with
pawn Код:
~n~
See the FAQ for more info.
It's like
pawn Код:
1. Hello~n~2. Hi~n~3. How are you?
Will give you something like
pawn Код:
1. Hello
2. Hi
3. How are you?
( not with \n )
That and make sure not to have space before and after!


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - pasha97 - 11.03.2013

Awesome include! I will surely use it! So easy! Btw, i think it would be more cool if we didnt need to create box, we just could write something like : SendTextdrawBoxMessage(playerid,color,text[],fadeouttime);


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - pasha97 - 11.03.2013

Hmm, It doesn't work for me. This is what I get:

Код:
G:\Ultra Fun Freeplay\gamemodes\UFFtest.pwn(23003) : error 017: undefined symbol "CreateTDBox"
G:\Ultra Fun Freeplay\gamemodes\UFFtest.pwn(23004) : error 017: undefined symbol "ShowTDBoxToPlayer"



Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - Rillo - 11.03.2013

Nice include, I was working on something similar only with a better looking textdraw
Good job!


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - greentarch - 12.03.2013

Quote:
Originally Posted by pasha97
Посмотреть сообщение
Hmm, It doesn't work for me. This is what I get:

Код:
G:\Ultra Fun Freeplay\gamemodes\UFFtest.pwn(23003) : error 017: undefined symbol "CreateTDBox"
G:\Ultra Fun Freeplay\gamemodes\UFFtest.pwn(23004) : error 017: undefined symbol "ShowTDBoxToPlayer"
PAWN is case-sensitive I think. You should use
pawn Код:
CreateTDbox // notice the b not capitalized
Instead of
pawn Код:
CreateTDBox



Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - Pottus - 12.03.2013

Going to recommend adding a player textdraw variant this is not coded correctly at all I'll explain why.

Код:
TextDrawSetString(Textdraw1, InfoBox[boxid][mTitle]);
TextDrawSetString(Textdraw3, InfoBox[boxid][mString]);
These lines here are a major problem as the textdraw strings will change for any player that has these textdraws currently displayed to the newly created infobox text that is not what we want!

The solution:

Use playertextdraws instead so each player has their own info box.

Also.....

Код:
	    if(InfoBox[i][mCreated] == false)
	    {
   			format(InfoBox[i][mString], 1024, "%s", string);
			format(InfoBox[i][mTitle], 50, "%s", title);
			format(InfoBox[i][mtColor], 14, "%s", titlecolor);
			InfoBox[i][mCreated] = true;
			return i;
		}
		else continue;
There is no need for using "else continue" here the loop is already at the end of it's scope and would iterate again at this point.

The good news is fixing this should take no more than 10 minutes.


Re: rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! - M3mPHi$_S3 - 12.03.2013

Did you use timer or what ?