How to set Ranks with ID

Topic created · 6 Posts · 253 Views
  • How to set Ranks with ID
    Developed by DoktorSAS
    With the new update all IDs have changed and are now all formed by an initial steam part.
    This part of steam is composed of n digits, these digits can be 10, 11 or 12.
    To overcome this system I created a script that takes the player's guide in DEC and turns it into HEX.
    That is, the player's GUID will turn into the id that IW4M admin will show you.
    Long Version

    //Developed by DoktorSAS
    DecToHex( dec ){
    	value = dec;
    	hex = "";
    	while(value > 0){
    	    newVal = (int(int(value)%16));
    	    if(newVal > 9){
    	    	switch(newVal){
    	    		case 10:
    	    			hex = "A" + hex ;
    	    		break;
    	    		case 11:
    	    			hex = "B" + hex ;
    	    		break;
    	    		case 12:
    	    			hex = "C" + hex ;
    	    		break;
    	    		case 13:
    	    			hex = "D" + hex ;
    	    		break;
    	    		case 14:
    	    			hex = "E" + hex ;
    	    		break;
    	    		case 15:
    	    			hex = "F" + hex ;
    	    		break;
    	    	}
    	    }else
    			hex = newVal + hex ;
    		value = (int(int(value)/16));
    	}
    	if((int(value)/16) > 0)
    		hex = hex + value;
    	return hex;
    }
    

    Short Version by @fed

    dec2hex(dec) {
    	hex = "";
    	digits = strTok("0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F", ",");
    	while (dec > 0) {
    		hex = digits[int(dec) % 16] + hex;
    		dec = floor(dec / 16);
    	}
    	return hex;
    }
    

    Example on how to use it ( with switch case)

    setRankWithSwitch(){
    	guid = DecToHex( self getguid());
    	switch( guid ){
    		case "INSERT IW4M GUID #1":
    			self.rank = "VIP";
    		break;
    		case "INSERT IW4M GUID #1":
    		case "INSERT IW4M GUID #2":
    		case "INSERT IW4M GUID #3":
    		case "INSERT IW4M GUID #5":
    		case "INSERT IW4M GUID #6":
    			self.rank = "MOD";
    		break;
    		case "INSERT IW4M GUID #7":
    			self.rank = "OWNER";
    		break;
    	}
    }
    

    Example on how to use it ( with IF and ELSE IF)

    setRankWithIF(){
    	guid = DecToHex( self getguid());
    	if( guid == "INSERT IW4M GUID #1"){
    			self.rank = "VIP";
    	}else if(guid == "INSERT IW4M GUID #1" ||
    			 guid == "INSERT IW4M GUID #2" ||
    			 guid == "INSERT IW4M GUID #3" ||
    			 guid == "INSERT IW4M GUID #5" ||
    			 guid == "INSERT IW4M GUID #6" ||){
    			 	self.rank = "MOD";
    	}else if(guid =="INSERT IW4M GUID #7":){
    		self.rank = "OWNER";
    	}
    }
    

    I hope that this little script can help all server owners in the management of rank in a server

  • Beautiful

  • dec2hex(dec) {
    	hex = "";
    	digits = strTok("0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F", ",");
    	while (dec > 0) {
    		hex = digits[int(dec) % 16] + hex;
    		dec = floor(dec / 16);
    	}
    	return hex;
    }
    

    cleaner

  • @fed Good job, I forgot about strTok. I added your code to the post

  • @Sorex is it league rank or is it up to the server's owners?

  • @Luv-Saint said in How to set Ranks with ID:

    is it league rank or is it up to the server's owners?

    this is dedicated to servers owner

Log in to reply