Sign in to follow this  
edouardlicn

why teleport?

Recommended Posts

Quote


    'tp2' : (player, _, x, y, z) => { 
    
        const playerposnow = player.position;
    
        if (!player.loggedIn || player.adminlvl < 1) { 
           let posnow = `x: ${misc.roundNum(playerposnow.x, 3)}, y: ${misc.roundNum(playerposnow.y, 3)}, z: ${misc.roundNum(playerposnow.z, 3)},`;
           player.position = new mp.Vector3(posnow);
        }       
        
        else {
            
             x = parseFloat(x);
             y = parseFloat(y);
             z = parseFloat(z);   
                
            if (isNaN(x) || isNaN(y) || isNaN(z)) {
            player.outputChatBox(`${i18n.get('sPlayer', 'tpHelp', player.lang)}`);
            return;
            }

            else player.position = new mp.Vector3(x, y, z);
            player.outputChatBox(`${i18n.get('sPlayer', 'tpOK', player.lang)}`);
         
        };
    },  

i try to make a teleport that if player is not admin that he wiil not teleport and stay on the original place,but i fail,it teleport to map center.pls give me some suggestion.

Share this post


Link to post
Share on other sites

maybe i'm out of memory but:

if you want to restrict a player from getting teleported, why you teleport him to his allready given location?

        if (!player.loggedIn || player.adminlvl < 1) { 
           let posnow = `x: ${misc.roundNum(playerposnow.x, 3)}, y: ${misc.roundNum(playerposnow.y, 3)}, z: ${misc.roundNum(playerposnow.z, 3)},`;
           player.position = new mp.Vector3(posnow);
        }       

would make more sense like that to me

'tp2' : (player, _, x, y, z) => { 
	if (!player.loggedIn || player.adminlvl > 0) { 
		x = parseFloat(x);
		y = parseFloat(y);
		z = parseFloat(z);
		if (isNaN(x) || isNaN(y) || isNaN(z)) {
		player.outputChatBox(`${i18n.get('sPlayer', 'tpHelp', player.lang)}`);
		return;
	} else {
		player.position = new mp.Vector3(x, y, z);
	};
	player.outputChatBox(`${i18n.get('sPlayer', 'tpOK', player.lang)}`); 
	};
},   

i'm not sure about your !player.loggedIn but you propably know best whats going on there.

 

  • Like 1

Share this post


Link to post
Share on other sites
12 hours ago, Larvell said:

maybe i'm out of memory but:

if you want to restrict a player from getting teleported, why you teleport him to his allready given location?

        if (!player.loggedIn || player.adminlvl < 1) { 
           let posnow = `x: ${misc.roundNum(playerposnow.x, 3)}, y: ${misc.roundNum(playerposnow.y, 3)}, z: ${misc.roundNum(playerposnow.z, 3)},`;
           player.position = new mp.Vector3(posnow);
        }       

would make more sense like that to me

'tp2' : (player, _, x, y, z) => { 
	if (!player.loggedIn || player.adminlvl > 0) { 
		x = parseFloat(x);
		y = parseFloat(y);
		z = parseFloat(z);
		if (isNaN(x) || isNaN(y) || isNaN(z)) {
		player.outputChatBox(`${i18n.get('sPlayer', 'tpHelp', player.lang)}`);
		return;
	} else {
		player.position = new mp.Vector3(x, y, z);
	};
	player.outputChatBox(`${i18n.get('sPlayer', 'tpOK', player.lang)}`); 
	};
},   

i'm not sure about your !player.loggedIn but you propably know best whats going on there.

 

thx,i fixed it later.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.