Raised This Month: $51 Target: $400
 12% 

random_num issue


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-16-2013 , 05:51   Re: random_num issue
Reply With Quote #11

He means, as claudiuhks already said, to check if destination string is not in arguments.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 07-16-2013 , 06:16   Re: random_num issue
Reply With Quote #12

Quote:
Originally Posted by ConnorMcLeod View Post
He means, as claudiuhks already said, to check if destination string is not in arguments.
I am not really sure....

If something is wrong - will compiler return an error or i can find problems only in real testing?
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 07-16-2013 , 06:17   Re: random_num issue
Reply With Quote #13

Quote:
Originally Posted by ConnorMcLeod View Post
He means, as claudiuhks already said, to check if destination string is not in arguments.
I am not really sure....

If something is wrong - will compiler return an error or i can find problems only in real testing?

ex from mutemenu
PHP Code:
    new nLen formatex(szMenuBodyMENU_SIZE-1g_menutitle[g_is_counterstrike], ""pos+1, (nNum MENU_PLAYERS + ((nNum MENU_PLAYERS) ? )))
    new 
nEnd nStart MENU_PLAYERS
    
new nKeys = (1<<9)
    
    if( 
nEnd nNum )
        
nEnd nNum
    
    
for(nStartnEndi++)
    {
        
iPlayerID g_nMenuPlayers[i]
        
get_user_name(iPlayerIDszUserName31)
        
        if(
access(iPlayerIDADMIN_KICK) || iPlayerID == id)
        {
            
nCurrKey++
            
nLen += formatex(szMenuBody[nLen], (MENU_SIZE-1-nLen), g_menutext1[g_is_counterstrike], nCurrKeyszUserName)
        }
        else
        {
            
nKeys |= (1<<nCurrKey++)
            
nLen += formatex(szMenuBody[nLen], (MENU_SIZE-1-nLen), g_menutext2[g_is_counterstrike], nCurrKey, (gb_mute[id][iPlayerID] ? "mute" ""), szUserName)
        }
    }
    
    if(
nEnd != nNum)
    {
        
formatex(szMenuBody[nLen], (MENU_SIZE-1-nLen), "^n9. More...^n0. %s"pos "Back" "Exit")
        
nKeys |= (1<<8)
    }
    else
        
formatex(szMenuBody[nLen], (MENU_SIZE-1-nLen), "^n0. %s"pos "Back" "Exit"
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-16-2013 , 08:26   Re: random_num issue
Reply With Quote #14

Compiler will never say anything about this.

In your example it is ok.

Check szMenuBody variable, when it is used as argument 4 or more, then you can't use formatex.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 07-16-2013 , 09:13   Re: random_num issue
Reply With Quote #15

Quote:
Originally Posted by ConnorMcLeod View Post
Compiler will never say anything about this.

In your example it is ok.

Check szMenuBody variable, when it is used as argument 4 or more, then you can't use formatex.
If i will - what will happen?

Would plugin return an error to log / server crash / or what else?
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-16-2013 , 09:15   Re: random_num issue
Reply With Quote #16

No, but string will be messed up

format(dest, charsmax(dest), "blabla %s", dest) is ok because format keeps dest in memory

Do the same with formatex, and when last argument is read, it is empty, or something like that, so you would have the end string : "blabla " instead of "blabla other chars"
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-16-2013 , 09:16   Re: random_num issue
Reply With Quote #17

I don't think an error will be generated, just the formatted string will not be as you expect
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Mofforg
Senior Member
Join Date: Aug 2010
Location: Moscow, Russia
Old 07-16-2013 , 09:42   Re: random_num issue
Reply With Quote #18

Thank you guys.

Last edited by Mofforg; 07-16-2013 at 09:42.
Mofforg is offline
Send a message via ICQ to Mofforg Send a message via Skype™ to Mofforg
Reply



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

Forum Jump


All times are GMT -4. The time now is 17:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode