Sign in to follow this  
sianbg

keker code /veh not working

Recommended Posts

Hello. I use keker code. First call /veh vehicle is created and work. When i use command again destroy is called, but vehicle stay and new vehicle not spawned. No errors in console. I dont know what happend. I have not edited the code.

  "veh": (player, args) =>
	{
        if(player.admin < 6) return player.outputChatBox("<span style='color:#ff2d00'>(!) Nu esti administrator!");
        if (typeof args[0] == 'undefined') return player.outputChatBox("<b style='color:#999'>(Syntax)</b> /veh [name]");
        if(!args[0].length) return player.outputChatBox("<b style='color:#999'>(Syntax)</b> /veh [name]");
        
		var pos = player.position;
		pos.x += 2.0;
			
		if(player.veh) {
			player.veh.destroy();
			console.log("destroy");
		} else {
			console.log("nqma");
		}
		

		
		player.veh = mp.vehicles.new(mp.joaat(args[0]), pos);
		player.veh.dimension = player.dimension;
		
		console.log("create");
		console.log(player.veh.engine);
		

        
        player.outputChatBox("You've spawn a " + args[0]);
	}

 

Share this post


Link to post
Share on other sites

Use this:

mp.events.addCommand('v',function(player,args,arg1){
	if(player.admin>=6&&typeof arg1!='undefined') {
      mp.vehicles.new(mp.joaat(arg1),player.position.x+2,player.position.y,player.position.z+2);
      player.outputChatBox('You\'ve spawn a '+arg1);
	}
});

 

Oh, yeah! Error was happend because player.veh only for read!

Use other variable.

Edited by kostya_nad

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.