Raised This Month: $ Target: $400
 0% 

couple questions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
0x00
SourceMod Donor
Join Date: Oct 2010
Location: #!/usr/bin/0x00
Old 12-01-2010 , 18:56   couple questions
Reply With Quote #1

first of, whats wrong with the following check:

PHP Code:
public function(id)
    if(
cs_get_user_team(id) < 2)
        
// something 
the syntax of such native is pretty simple, i really can't see any mistake. anyway, in sourcepawn you could do the following:

PHP Code:
new string:temp[1024]

public function()
    switch(
something)
    {
        case 
1temp "my text"
        
case 2temp "my text 2"

        
// and so on
    

but you can't do the following on amxx, so please, tell me whats wrong.

PHP Code:
new temp[1024]

public function()
    switch(
something)
    {
        case 
1temp "my text"
        
case 2temp "my text 2"

        
// and so on
    

and the last question, whats wrong with:

PHP Code:
get_randplayer()
{
    
/*
    using get_players() because i really don't
    need to do any check, like teams, etc. so get_maxplayers()
    isnt really needed.
    */

    
new players[get_players() + 1], num
    
    
for(new 1<= get_maxplayers(); x++)
        if(
cs_get_user_team(x) > 1)
            
players[num++] = x
            
    
return (num == 0) ? - players[random_num(0num 1)]

it kept saying that it must be a constant, which does not happen on sourcepawn. ty.

Last edited by 0x00; 12-01-2010 at 18:58. Reason: fixed a typo
0x00 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-01-2010 , 19:06   Re: couple questions
Reply With Quote #2

Quote:
Originally Posted by 0x00 View Post
first of, whats wrong with the following check:

PHP Code:
public function(id)
    if(
cs_get_user_team(id) < 2)
        
// something 
That's a tag mismatch error.

the syntax of such native is pretty simple, i really can't see any mistake.
Either change 2 to CS_TEAM_CT, or untag the function.

Quote:
Originally Posted by 0x00 View Post
anyway, in sourcepawn you could do the following:

PHP Code:
new temp[1024]

public function()
    switch(
something)
    {
        case 
1temp "my text"
        
case 2temp "my text 2"

        
// and so on
    

but you can't do the following on amxx, so please, tell me whats wrong.
You should use the copy() function.
PHP Code:
copy(temp1023"my text"
Quote:
Originally Posted by 0x00 View Post
and the last question, whats wrong with:

PHP Code:
get_randplayer()
{
    
/*
    using get_players() because i really don't
    need to do any check, like teams, etc. so get_maxplayers()
    isnt really needed.
    */

    
new players[get_players() + 1], num
    
    
for(new 1<= get_maxplayers(); x++)
        if(
cs_get_user_team(x) > 1)
            
players[num++] = x
            
    
return (num == 0) ? - players[random_num(0num 1)]

it kept saying that it must be a constant, which does not happen on sourcepawn. ty.
You can't create an array of a dynamic size like that.
The size has to be a constant number at compile time.
Therefore, use 32 because it will always be big enough for all players.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
0x00
SourceMod Donor
Join Date: Oct 2010
Location: #!/usr/bin/0x00
Old 12-01-2010 , 19:20   Re: couple questions
Reply With Quote #3

thanks.
0x00 is offline
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 11:26.


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