SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/08/2017, 02:45 AM   #4311
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,449
Reputation: 515
Default Re: Little coding questions - For general minor queries 5

Yes, it's normal. As for benefits as best as Y_Less on github
Misiur is offline   Reply With Quote
Old 11/08/2017, 04:34 PM   #4312
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,445
Reputation: 120
Default Re: Little coding questions - For general minor queries 5

Is it better to create and destroy textdraw or create it one time and show/hide when it's needed?
__________________
What matters isn't to going further, it's the way to get there
Dayrion is offline   Reply With Quote
Old 11/08/2017, 05:41 PM   #4313
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 11,045
Reputation: 2647
Default Re: Little coding questions - For general minor queries 5

I don't see the point in recreating them, honestly. More function calls, thus slower.
__________________
Vince is offline   Reply With Quote
Old 11/08/2017, 05:58 PM   #4314
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 502
Reputation: 58
Default Re: Little coding questions - For general minor queries 5

B.

Create one time and show/hide them.

Like Vince said Recreating them over n over is useless and you wouldn't want to do that, it will catch up on you if you intend to use a lot of textdraws.
ISmokezU is offline   Reply With Quote
Old 12/08/2017, 02:39 PM   #4315
GaByM
Big Clucker
 
GaByM's Avatar
 
Join Date: Jan 2014
Location: Romania
Posts: 61
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Spmn View Post
Thank you!

Quote:
Originally Posted by Jeroen52 View Post
Do you have some examples?
Yes, I have
PHP Code:
CMD:coin(playerid,params[])
{
    new 
random(600), s[100];
    
strcat(s,"* ");
    
strcat(s,nume[playerid]);
    if(
== 0)
        
strcat(s" has thrown the coin and landed on the edge.");
    else
    {   
random(100);
        if(
50)
            
strcat(s," has thrown the coin and landed on the head side.");
        else
            
strcat(s," has thrown the coin and landed on the tail side.");
    }
    
sendArea(playerid20CP3s);
    return 
1;

Sometimes, this gives the same result in a row (head/tail). I know that something random is supposed to be like that, but 8-9 times in a row? Maybe it is my fault because I used a big number (100), maybe I should use a smaller interval (0 to 10? or to 2?), but anyway, is not such a big deal with /coin cmd, it is just trivial.

I plan to make a lottery/roulette system (sometime), and I didn't wanted to use random for the reason previously mentioned, but as you said random is random so I am going to use sa:mp's native, at least for now.
GaByM is offline   Reply With Quote
Old 12/08/2017, 04:16 PM   #4316
oMa37
High-roller
 
oMa37's Avatar
 
Join Date: Feb 2016
Posts: 1,033
Reputation: 152
Default Re: Little coding questions - For general minor queries 5

What could cause calling the OnPlayerDeath twice? In my gamemode it seems like it's getting called twice when the player dies in event/minigame.

EDIT: Well, It looks like it's calling like this: OnPlayerDeath -> OnPlayerSpawn -> OnPlayerDeath -> OnPlayerRequestClass -> OnPlayerSpawn
oMa37 is offline   Reply With Quote
Old 12/08/2017, 04:40 PM   #4317
Sew_Sumi
High-roller
 
Join Date: Jun 2008
Posts: 4,973
Reputation: 369
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by oMa37 View Post
What could cause calling the OnPlayerDeath twice? In my gamemode it seems like it's getting called twice when the player dies in event/minigame.
Using a filterscript and gamemode that hasn't had the callback excluded via checks.
Sew_Sumi is online now   Reply With Quote
Old 12/08/2017, 04:42 PM   #4318
oMa37
High-roller
 
oMa37's Avatar
 
Join Date: Feb 2016
Posts: 1,033
Reputation: 152
Default Re: Little coding questions - For general minor queries 5

I don't use filterscripts also I made checks.
oMa37 is offline   Reply With Quote
Old 12/08/2017, 04:54 PM   #4319
Sew_Sumi
High-roller
 
Join Date: Jun 2008
Posts: 4,973
Reputation: 369
Default Re: Little coding questions - For general minor queries 5

You need to post a thread and submit some code... This isn't a minor query.
Sew_Sumi is online now   Reply With Quote
Old 14/08/2017, 10:42 AM   #4320
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 11,045
Reputation: 2647
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by GaByM View Post
I know that something random is supposed to be like that, but 8-9 times in a row?
You may want to check this: https://www.random.org/coins/?num=20&cur=60-usd.0010c. On my attempt I got tails 8 times in a row. Random.org prides itself on providing true randomness based on atmospheric noise.
__________________
Vince is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a soldier aotumaticly be general when the general dies ? AlbanianGuy Scripting Help 35 13/05/2012 04:35 PM
Minor problem Desert Help Archive 4 17/03/2010 07:24 PM
Counting with mysql queries actiwe Help Archive 2 26/02/2010 03:36 PM
SQL queries using GROUP BY Dabombber Help Archive 2 05/10/2009 08:47 PM


All times are GMT. The time now is 05:46 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.