AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   some advices and corrections? (https://forums.alliedmods.net/showthread.php?t=187699)

n0br41ner 06-16-2012 17:57

some advices and corrections?
 
Alright before you read this code, i am relatively at new coding. I have intermediate (maybe a bit more) knowledge in c++, but i want to learn amxx scripting. I have had this idea for a while about his plugin.
It basically on command searches for players with the same ip. And by cvar, blackout (mp_fadetoblack like function) those players when dead.

NOTE: i am pretty aware that this plugin might have a lot of bad written stuff but you gotta learn someday :D also i couldn't test it all by myself, and that's why i came to you guys for help :D
I put a lot of comments so i don't forget :P (force of habit :D)

Now on to the code
EDIT: code removed

I appreciate any help from anyone, thank you :D
P.S.: i just wanted to thank MPNumB a lot, he has been very kind to me in helping me immensly with this :D

I am planning on releasing this plugin as soon as it becomes stable.
If you have any questions about a part of the code, let me know :D

Neeeeeeeeeel.- 06-16-2012 18:22

Re: some advices and corrections?
 
PHP Code:

for(new 1g_iMaxPlayersi++) 

-->
PHP Code:

for(new 1<= g_iMaxPlayersi++) 

--------------------------------------------------------
PHP Code:

g_iMaxPlayers clamp(get_maxplayers(), 132); 

-->
PHP Code:

g_iMaxPlayers get_maxplayers(); 

--------------------------------------------------------
PHP Code:

get_user_ip(ig_iPlayersIP[i], 151); 

-->
PHP Code:

get_user_ip(ig_iPlayersIP[i], charsmaxg_iPlayersIP[ ] ) , 1); 

--------------------------------------------------------
PHP Code:

for(new 032i++) {
    
g_bSameIPs[i] = false;
}    

// Looping through all players and comparing IPs
for(new 133i++) {
    if(
i%!=0) {
        for(new 
115j++) {
            
// If IP does not match, set bFound as false
            
if(g_iPlayersIP[j][j] != g_iPlayersIP[j+1][j]) {
                
bFound false;
            }    
        }
    
        
// If bFound is true, change g_bSameIPs accordingly
        
if(bFound) {
            
iFoundCounter++;
            
g_bSameIPs[i]     = true;
            
g_bSameIPs[i++] = true;
        }
    }


-->
PHP Code:

// Looping through all players and comparing IPs
for(new 1<= g_iMaxPlayersi++) {
    if( 
is_user_connected) )
    {
        
g_bSameIPs[i] = false;
        if(
i%!=0) {
            for(new 
115j++) {
                
// If IP does not match, set bFound as false
                
if(g_iPlayersIP[j][j] != g_iPlayersIP[j+1][j]) {
                    
bFound false;
                }    
            }
        
            
// If bFound is true, change g_bSameIPs accordingly
            
if(bFound) {
                
iFoundCounter++;
                
g_bSameIPs[i]     = true;
                
g_bSameIPs[i++] = true;
            }
        }
    }


And the same corrections from the other loops...

n0br41ner 06-16-2012 18:29

Re: some advices and corrections?
 
[php]for(new i = 1; i <= g_iMaxPlayers; i++) [php]
thank you i have missed that :D

PHP Code:

g_iMaxPlayers clamp(get_maxplayers(), 132); 

i think thats better since if max_players is lower than 1 it returns 1
and if its bigger than 32 it returns 32
m i wrong?

PHP Code:

get_user_ip(ig_iPlayersIP[i], charsmaxg_iPlayersIP[ ] ) , 1); 

thank you again :D

PHP Code:

// Looping through all players and comparing IPs
for(new 1<= g_iMaxPlayersi++) {
    if( 
is_user_connected)
    {
        
g_bSameIPs[i] = false;
        if(
i%!=0) {
            for(new 
115j++) {
                
// If IP does not match, set bFound as false
                
if(g_iPlayersIP[j][j] != g_iPlayersIP[j+1][j]) {
                    
bFound false;
                }    
            }
        
            
// If bFound is true, change g_bSameIPs accordingly
            
if(bFound) {
                
iFoundCounter++;
                
g_bSameIPs[i]     = true;
                
g_bSameIPs[i++] = true;
            }
        }
    }


fixed :D

ill fix the code in a moment
EDIT: code updated :D

Exolent[jNr] 06-16-2012 18:53

Re: some advices and corrections?
 
Quote:

Originally Posted by n0br41ner (Post 1730081)
PHP Code:

g_iMaxPlayers clamp(get_maxplayers(), 132); 

i think thats better since if max_players is lower than 1 it returns 1
and if its bigger than 32 it returns 32
m i wrong?

You are right, but max players will always be 1 to 32 since that is the only available range for CS.
Therefore, there's no reason to make that check.

n0br41ner 06-16-2012 18:54

Re: some advices and corrections?
 
By hard coding servers are able to go up to several hundred of players :)
At least that's what I herd, and I think I saw such a server back in the days

Exolent[jNr] 06-16-2012 18:59

Re: some advices and corrections?
 
Quote:

Originally Posted by n0br41ner (Post 1730101)
By hard coding servers are able to go up to several hundred of players :)
At least that's what I herd, and I think I saw such a server back in the days

It's not possible to have more than 32 players in a CS 1.6 or valid HL1 game.

n0br41ner 06-16-2012 19:02

Re: some advices and corrections?
 
Since it won't Make a difference, I removed that piece :)
Any other corrections?

Neeeeeeeeeel.- 06-16-2012 19:30

Re: some advices and corrections?
 
PHP Code:

Print(iPlayerID); 

I think that's not possible...

To show into server console:
PHP Code:

console_printid"%d"iPlayerID ); 


n0br41ner 06-16-2012 19:53

Re: some advices and corrections?
 
Why isn't it possible, I'm passing the I'd of the player who used the command in order to print it in their console of the players who have the same ip.

What's the difference between console_print() and client_print( , print_console, ) ???

Neeeeeeeeeel.- 06-16-2012 22:27

Re: some advices and corrections?
 
Quote:

Originally Posted by n0br41ner (Post 1730141)
Why isn't it possible, I'm passing the I'd of the player who used the command in order to print it in their console of the players who have the same ip.

What's the difference between console_print() and client_print( , print_console, ) ???

But there is not any native called "Print" in amxmodx.

At least in functionality, there is no difference.


All times are GMT -4. The time now is 06:16.

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