[Include] Single-Player Info Boxes
#1

Single-Player Info Boxes
Description

Single-player info boxes brings the informational boxes from single-player to San Andreas Multiplayer with the ability to change the box' color, text to display and time to be shown (until the box disappears).

Functions
  • ShowInfoBox(playerid, box_color, shown_for, text[]);

    playerid - The player to display the textdraw for.
    box_color - The color of the box.
    shown_for - The time that the info box will be shown for (in seconds).
    text[] - Text to display within the box.
Screenshots















Download

https://github.com/KevinMarapao/Sing...yer-Info-Boxes
Reply
#2

Awesome work i love it!
Reply
#3

Awesome man! I've been looking for this quite a while!
Reply
#4

This is simple but good job!
Reply
#5

Mabye u can help me i using this, trying to get the box black but this not work ----> 0x00000000

PHP код:
ShowInfoBox(playerid0x000000005"~r~Server Rules: ~w~You can find the Rules list on Forum.rebound-rp.com > Server Information > Server Rules.!"); 
Reply
#6

How to do the black box to be on low opacity?
Reply
#7

0xRRGGBBAA

AA is your opacity.

@N0FeaR: You are setting the opacity to 00, so it wont be visible. Try 0x000000FF.

@kevIn: You do kill the timer but where do you check if its existing or not.

Refrence: http://forum.sa-mp.com/showpost.php?...4&postcount=11
Reply
#8

Quote:
Originally Posted by Gammix
Посмотреть сообщение
0xRRGGBBAA

AA is your opacity.

@N0FeaR: You are setting the opacity to 00, so it wont be visible. Try 0x000000FF.
Getting error after comiling the pawno when I try to test it -

error 025: function heading differs from prototype

under OnPlayerConnect
Reply
#9

Quote:
Originally Posted by DemME
Посмотреть сообщение
Getting error after comiling the pawno when I try to test it -

error 025: function heading differs from prototype

under OnPlayerConnect
Did you put RR/GG/BB while adding color? RR, GG, BB are just to give an example/sense to my statement. These are actually integer / hex values.

For example:
pawn Код:
0xFF0000FF
Here RR = FF(opaque), GG = 0, BB =0, AA = FF(opaque). This is a red color with 255 opacity.
Reply
#10

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Did you put RR/GG/BB while adding color? RR, GG, BB are just to give an example. These are actually integer / hex values.

For example:
pawn Код:
0xFF0000FF
Here RR = FF(opaque), GG = 0, BB =0, AA = FF(opaque). This is a red color with 255 opacity.
the color is fine I assume, I've tried to contact it with format, which means I wanna put it in the house system. -

PHP код:
format(stringsizeof(string), "Owned house\nAddress: %s"HouseData[houseid][houseAddress]);
ShowInfoBox(houseid0xFF0000FF10string); 
Tried to do some kind of it, but it's not working. and it gives me the error that I gave above

Edit: Doesn't matter where I try to put it, or just use a cmd with a random text, it still gives me that error..
Reply
#11

Quote:
Originally Posted by Gammix
Посмотреть сообщение
0xRRGGBBAA

AA is your opacity.

@N0FeaR: You are setting the opacity to 00, so it wont be visible. Try 0x000000FF.

@kevIn: You do kill the timer but where do you check if its existing or not.

Refrence: http://forum.sa-mp.com/showpost.php?...4&postcount=11
Works, thanks!
Reply
#12

Quote:
Originally Posted by Gammix
Посмотреть сообщение
0xRRGGBBAA

AA is your opacity.

@N0FeaR: You are setting the opacity to 00, so it wont be visible. Try 0x000000FF.

@kevIn: You do kill the timer but where do you check if its existing or not.

Refrence: http://forum.sa-mp.com/showpost.php?...4&postcount=11
Quote:
Originally Posted by Wiki
Timer IDs are never used twice. You can use KillTimer() on a timer ID and it won't matter if it's running or not.
There is no need to add an extra unnecessary condition. That "KillTimer()" is only there to kill the current running timer (if the public function that hides the textdraw hasn't been called yet and a new "ShowInfo()" function has been executed) so that the textdraw won't be hidden earlier than it is suppose to be shown for.

@DemME:
pawn Код:
format(string, sizeof(string), "Owned house\nAddress: %s", HouseData[houseid][houseAddress]);
ShowInfoBox(playerid, 0xFF0000FF, 10, string);
Reply
#13

Quote:

You can use KillTimer() on a timer ID and it won't matter if it's running or not.

Completely clarify your mistake.

If you create 2 variables for timers:
pawn Код:
new timer1;
new timer2
Now you set variable "timer1" on a timer, but don't for the second.
pawn Код:
timer1 = SetTimer(...);
Now you try to kill "timer2" even if you haven't set it (according to you it doesn't matter)
pawn Код:
KillTimer(timer2);
Your timer1 will be killed in this case, because both have "0" as their default value, and timer1 is set to 0 as well as a first index for a timer. Same is happening in your script.
Reply
#14

Nice job, man. Simple, but awesome.
Reply
#15

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Completely clarify your mistake.

If you create 2 variables for timers:
pawn Код:
new timer1;
new timer2
Now you set variable "timer1" on a timer, but don't for the second.
pawn Код:
timer1 = SetTimer(...);
Now you try to kill "timer2" even if you haven't set it (according to you it doesn't matter)
pawn Код:
KillTimer(timer2);
Your timer1 will be killed in this case, because both have "0" as their default value, and timer1 is set to 0 as well as a first index for a timer. Same is happening in your script.
Timer IDs start at 1 and despite the fact that timer IDs are never used again, there is absolutely no need to initialize a variable beforehand to validate whether a timer is running or not.

Your message is logical, but it's just another wrong theory (timer IDs start at 1, the wiki is wrong as far as I am aware of).
Reply
#16

The include everytime keeps to give me an error under "OnPlayerConnect"
Quote:

error 025: function heading differs from prototype

Everytime I try to include the inc, it gives me that error ^
Anyway, maybe thats something inside the include itself.
Reply
#17

Quote:
Originally Posted by DemME
Посмотреть сообщение
The include everytime keeps to give me an error under "OnPlayerConnect"

Everytime I try to include the inc, it gives me that error ^
Anyway, maybe thats something inside the include itself.
The hooking method has been updated (addressing that problem and another one as well), please re-download the include. I'm sorry for any inconveniences, and thanks guys!
Reply
#18

Lets say we use you function
pawn Код:
ShowInfoBox(..);
Now the timer id stored is 1. Just after the timer ends, we execute a custom timer:
pawn Код:
SetTimer("very_important_timer", ...);
Its id is 1 as well, but just after execution, we use your function again (note the custom timer is still alive):
pawn Код:
ShowInfoBox(..);
Your include kills "very_important_timer" timer, because as i previously mentioned, you don't have a check, or you don't reset the variable to "0" when the timers are no more running.
Reply
#19

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Lets say we use you function
pawn Код:
ShowInfoBox(..);
Now the timer id stored is 1. Just after the timer ends, we execute a custom timer:
pawn Код:
SetTimer("very_important_timer", ...);
Its id is 1 as well, but just after execution, we use your function again (note the custom timer is still alive):
pawn Код:
ShowInfoBox(..);
Your include kills "very_important_timer" timer, because as i previously mentioned, you don't have a check, or you don't reset the variable to "0" when the timers are no more running.
Timer. IDs. Are. Never. Used. Twice.

We execute a timer, its ID will be 1. We execute another timer, its ID will be 2. We execute another timer, its ID will be 3. We execute another timer, its ID will be 4. We execute another timer, its ID will be 5. We execute another timer, its ID will be 6. We execute another timer, its ID will be 7. We execute another timer, its ID will be 8. We execute another timer, its ID will be 9. We execute another timer, its ID will be 10. Etc, etc, etc.
Reply
#20

Quote:

Now the timer id stored is 1. Just after the timer ends, we execute a custom timer:

"Just after the timer ends", meaningful ?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)