AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Small function crashing server without error logs (https://forums.alliedmods.net/showthread.php?t=315615)

deprale 04-15-2019 08:18

Small function crashing server without error logs
 
PHP Code:

new sv_password
public plugin_init(){
  
sv_password get_cvar_pointer"sv_password" );
  
register_concmd("amx_pass""passfunc"ADMIN_KICK"duhh")
}


public 
passfunc(id){
    new 
pass random_num(0,10000)
    new 
currpass32 ];
    
get_pcvar_stringsv_password currpass charsmaxcurrpass ) );
    if(
get_pcvar_num(currpass] == EOS )){
        
set_cvar_num("sv_password"pass);
    }
    if(
get_pcvar_num(currpass] != EOS )){
        
set_cvar_string("sv_password","");
    }


basically, this stuff's crashing my server without any error log

CrazY. 04-15-2019 09:22

Re: Small function crashing server without error logs
 
Code:
public passfunc(id){     new pass = random_num(0,10000)     new currpass[ 32 ];     get_pcvar_string( sv_password , currpass , charsmax( currpass ) );     //if(get_pcvar_num(currpass[ 0 ] == EOS )){     if (equal(currpass, "EOS")) {         set_cvar_num("sv_password", pass);     }     else {         set_cvar_string("sv_password","");     } }

deprale 04-15-2019 13:04

Re: Small function crashing server without error logs
 
Thanks CrazY, can always rely on you :D

EDIT: THOUGHT I MIGHT SHARE IT, it actually didnt work, it did compile though but it never passed the first if, only the "else" statement somehow.
ALTHOUGH - you can use strlen(currpass) == 0 instead of EQUAL EOS and fix the problem.

HamletEagle 04-16-2019 07:57

Re: Small function crashing server without error logs
 
Yeah the equal "EOS" doesn't make sense. It should be currpass[0] == EOS

Natsheh 04-16-2019 09:01

Re: Small function crashing server without error logs
 
btw if you are using a version of amx modx doesnt have EOS in defines EOS is equal to 0..

EOS : End Of String

deprale 04-16-2019 14:02

Re: Small function crashing server without error logs
 
Thanks @HamletEagle, @Natsheh, for the added info!


All times are GMT -4. The time now is 05:11.

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