Help with .@atcmd_parameters$[]

Tsuuu

New member
Messages
80
Points
0
Emulator
Good Morning, could someone tell me how I can remove this 'warning' in map-server:

Screenshot_1.jpg

Here is the script:

bindatcmd "warp",strnpcinfo(3)+"::OnAtcommand4";

Code:
OnAtcommand4:	
getmapxy @map$,@x,@y,0;	
if(@map$=="bra_dun01") { 
	message strcharinfo(0),"WARP OFF.";
	end; 
	} else {

		if(.@atcmd_parameters$[1])
		{
			if ( WARPCOORCD + 5 > gettimetick(2) ) {
				message strcharinfo(0),"[Delay Warp com Coordenadas] ---> Você precisa esperar " + ( WARPCOORCD + 5 - gettimetick(2) ) + " segundos.";		
				end;	
			} else {
				atcommand "@warp "+.@atcmd_parameters$[0]+" "+.@atcmd_parameters$[1]+" "+.@atcmd_parameters$[2]+"";
				WARPCOORCD = gettimetick(2);
				end;
			}
		} else {
			atcommand "@warp "+.@atcmd_parameters$[0]+"";
		}

	}
}

PS: I'm a beginner, so please do not repair the code, just help me optimize it.

PS²: I sure use hercules.

 
The problem is at:

if(.@atcmd_parameters$[1])

if expression must result in a number (0 for false or other numbers for true) and there you're giving it a string (notice the $).

I'm not sure what you're trying to compare there, but a example would be:

if(.@atcmd_parameters$[1] == "1") // runs if parameters[1] is equal to 1

Maybe you're trying to check if the parameter exists? It would probably be better to use .@atcmd_numparameters instead. Example:

if (.@atcmd_numparameters == 2) // So parameters[0] and parameters[1] exists
Hope this helps

 
I'm at work and I can not test now, as soon as I get home I'm going to test, thank you very much for helping me, I'll return on this topic to notify you if it worked or not

@edit

Forgive me the delay, you helped me, thank you very much, could you inform me where I see the documentation of these parameter commands?

It stayed like this, works perfectly without any warning on the map-serv:

Code:
OnAtcommand4:    
getmapxy @map$,@x,@y,0;    
if(@map$=="bra_dun01") {
    message strcharinfo(0),"WARP OFF.";
    end;
    } else {
    
        if(.@atcmd_numparameters == 3)
        {
            if ( WARPCOORCD + 5 > gettimetick(2) ) {
                dispbottom "[Delay Warp com Coordenadas] ---> Você precisa esperar " + ( WARPCOORCD + 5 - gettimetick(2) ) + " segundos.";        
                end;    
            } else {
                atcommand "@warp "+.@atcmd_parameters$[0]+" "+.@atcmd_parameters$[1]+" "+.@atcmd_parameters$[2]+"";
                WARPCOORCD = gettimetick(2);
                end;
            }
        } else if(.@atcmd_numparameters == 2){
        
            dispbottom "Você utilizou o warp com coordenadas erradas, corriga o comando.";
            end;
            
        } else {
            atcommand "@warp "+.@atcmd_parameters$[0]+"";
        }

    }
}
 
Last edited by a moderator:
Back
Top