Raised This Month: $ Target: $400
 0% 

about id = str_to_num


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
epic .
Senior Member
Join Date: Oct 2009
Location: China
Old 05-04-2010 , 01:12   about id = str_to_num
Reply With Quote #1

Code:
public plugin_init()
{
    register_srvcmd("bot","bot_interface")
}
 
public bot_interface()
{
    new sid[8],id
    read_argv(1,sid,7)
    id = str_to_num(sid)
    A_function(id)
 
    return PLUGIN_CONTINUE
}
What does the "id" means here ?
__________________
Quote:
Destinies in my AWP sight are all alike;
Destinies out of my AWP sight in its own way.

Last edited by epic .; 05-04-2010 at 01:17.
epic . is offline
Send a message via ICQ to epic .
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 05-04-2010 , 01:20   Re: about id = str_to_num
Reply With Quote #2

It's a player index. For example, if sid was equal to "27", id would be 27. It converts the string to a number and stores the numerical value in id.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
epic .
Senior Member
Join Date: Oct 2009
Location: China
Old 05-04-2010 , 01:33   Re: about id = str_to_num
Reply With Quote #3

I still confused.
What`s the difference between this :
Code:
public bot_interface()
{
    for ( new i = 0 ; i < iNum ; i++ )
    {
        id = iPlayers[i];
    }
}
__________________
Quote:
Destinies in my AWP sight are all alike;
Destinies out of my AWP sight in its own way.
epic . is offline
Send a message via ICQ to epic .
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-04-2010 , 01:38   Re: about id = str_to_num
Reply With Quote #4

Quote:
Originally Posted by epic . View Post
I still confused.
What`s the difference between this :
Code:
public bot_interface()
{
    for ( new i = 0 ; i < iNum ; i++ )
    {
        id = iPlayers[i];
    }
}
In the first situation, a command executed in the console by a player is being processed. Like if you do in console

Code:
command 27
The id is in the middle of a string, so it is converted from a string to a number. "27" becomes 27.

In the second situation you are using a loop that is used to do some action over all players (using their ID's).

Basically, "ID" means the same in both examples but its used in different contexts.
__________________
joaquimandrade is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 05-04-2010 , 03:44   Re: about id = str_to_num
Reply With Quote #5

Quote:
Originally Posted by epic . View Post
I still confused.
What`s the difference between this :
Code:
public bot_interface()
{
    for ( new i = 0 ; i < iNum ; i++ )
    {
        id = iPlayers[i];
    }
}
I think you can do like this :
PHP Code:
public bot_interface()
{
    static 
rag[8]
    
read_ragv(1rag7)
    for ( new 
iNum i++ )
    {
        
id iPlayers[i];
        if (
id == str_to_num(rag))
                
A_function(id)
                break
    }

but I think it's not a good way !
so you need not to use loop !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2010 , 18:00   Re: about id = str_to_num
Reply With Quote #6

Quote:
Originally Posted by epic . View Post
Code:
public plugin_init()
{
    register_srvcmd("bot","bot_interface")
}
 
public bot_interface()
{
    new sid[8],id
    read_argv(1,sid,7)
    id = str_to_num(sid)
    A_function(id)
 
    return PLUGIN_CONTINUE
}
What does the "id" means here ?
Quote:
Originally Posted by wrecked_ View Post
It's a player index. For example, if sid was equal to "27", id would be 27. It converts the string to a number and stores the numerical value in id.
You are assuming the first argument is a player id because he used the variable name "id". But, infact, it will be what ever string is passed as the first argument of the server command that which is then converted to a integer. So, if you type in

Code:
bot 12325434
id will be 12325434 which definitely is not a player id.
__________________
fysiks is offline
epic .
Senior Member
Join Date: Oct 2009
Location: China
Old 05-04-2010 , 02:03   Re: about id = str_to_num
Reply With Quote #7

Thanks for help. The matter is : There is a plugin use the code that I posted in the thread, to make Bots do a function.
It just "new sid[8]", it doesn`t equal sid[8] to any numbers, how can the "A_function" know the "id" is the bots?
__________________
Quote:
Destinies in my AWP sight are all alike;
Destinies out of my AWP sight in its own way.

Last edited by epic .; 05-04-2010 at 02:07.
epic . is offline
Send a message via ICQ to epic .
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

Forum Jump


All times are GMT -4. The time now is 03:40.


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