Jump to content

I got a problem for this code of changing infernus skin and asking for something


ZeaD22

Recommended Posts

Hello , 

i made an infernus skin , and got a code to run it , i added somethings in the code to have good looking

but one of newly added isn't working i need help to fix it

 

and i want to make the command /xmas enables and disables the skin

the code i got from internet  (client): 

infernusTexture = engineLoadTXD ( "infernus.txd" )
engineImportTXD ( infernusTexture, 411 )
infernusTexture = engineLoadDFF ( "infernus.dff", 411 )
engineReplaceModel ( infernusTexture, 411 )

i made server side :

----------------------  Made by ZeaD22 ----------------------

function e ()

	outputChatBox(" ",player,0,0,0,true) 

end

	addEventHandler("onResourceStart",getRootElement(),function ()

			e()
			outputChatBox("#ff9999Hello "..getPlayerName(source).." #ff9999, Merry Christmas :) .",player,0,0,0,true)
			e()
			outputChatBox("#ff9999To Enable / Disable The Christmas Infernus Skin , Please use the command #ff0000/xmas",player,0,0,0,true)
			e()
			outputChatBox("#ff9999 Note : This Mode Made By : #286699-DG|#Zea#990000D22",player,0,0,0,true)
			e()

		end

	)

	addCommandHandler("xmas" , 

			function ()

			e()
			outputChatBox("#ff9999Congratulations , You have Enabled The Christmas Infernus Skin",player,0,0,0,true)
			e()
			outputChatBox("#ff9999 Note : This Mode Made By : #286699-DG|#Zea#990000D22",player,0,0,0,true
			e()

		end

	)
	
	
----------------------  Made by ZeaD22 ----------------------

And the problem is here... it says ERROR: skin\server.lua:12: attemp to concatenate a boolean value (the line which gets player name , when i removed it  and made the line like that :

	outputChatBox("#ff9999Hello  #ff9999, Merry Christmas :) .",player,0,0,0,true)

the code ran correctly )

 

and the ask is : can i make the command /xmas enable and disable the skin ?

 

Client side : 

----------------------  Made by ZeaD22 ----------------------
	
	function car()
	
		infernusTexture = engineLoadTXD ( "infernus.txd" )
		engineImportTXD ( infernusTexture, 411 )
		infernusTexture = engineLoadDFF ( "infernus.dff", 411 )
		engineReplaceModel ( infernusTexture, 411 )
	
	end
	
	addCommandHandler("xmas",car)
	
	
----------------------  Made by ZeaD22 ----------------------

 

Link to comment
11 hours ago, ZeaD22 said:

 


----------------------  Made by ZeaD22 ----------------------

			outputChatBox("#ff9999Hello "..getPlayerName(source).." #ff9999, Merry Christmas :) .",player,0,0,0,true)


----------------------  Made by ZeaD22 ----------------------

And the problem is here... it says ERROR: skin\server.lua:12: attemp to concatenate a boolean value 

 

isnt there any help for this ???

Link to comment

i made it

	outputChatBox("#ff9999Hello "..getPlayerName(player).." #ff9999, Merry Christmas :) .",player,0,0,0,true)

says WARNING: skin\server.lua:12: Bad argument @ 'getPlayerName'  [Expected element at argument 1 , got nil ]

and WARNING: skin\server.lua:12: attemp to concatenate a boolean value 

i  got help from wiki and put onPlayerJoin instead of onResourceStart and put  source again instead of player and it worked correctly

	addEventHandler("onPlayerJoin",getRootElement(),function ()

			e()
			outputChatBox("#ff9999Hello "..getPlayerName(source).." #ff9999, Merry Christmas :) .",player,0,0,0,true)
			e()
			outputChatBox("#ff9999To Enable / Disable The Christmas Infernus Skin , Please use the command #ff0000/xmas",player,0,0,0,true)
			e()
			outputChatBox("#ff9999 Note : This Mode Made By : #286699-DG|#Zea#990000D22",player,0,0,0,true)
			e()

		end

	)

 

Link to comment
22 minutes ago, ZeaD22 said:

i made it


	outputChatBox("#ff9999Hello "..getPlayerName(player).." #ff9999, Merry Christmas :) .",player,0,0,0,true)

says WARNING: skin\server.lua:12: Bad argument @ 'getPlayerName'  [Expected element at argument 1 , got nil ]

and WARNING: skin\server.lua:12: attemp to concatenate a boolean value 

You also have to pass argument of that player (like: e(player)).

But not to unnecessarily complicate things, what you want to do can be easily done using only client-side.

Example (untested):

local replaced = false
	
function car()
	if replaced then
		engineRestoreModel(411)
		replaced = false
	else
		infernusTexture = engineLoadTXD("infernus.txd")
		engineImportTXD(infernusTexture, 411)
		infernusTexture = engineLoadDFF("infernus.dff", 411)
		engineReplaceModel(infernusTexture, 411)
		replaced = true
	end
end
addCommandHandler("xmas", car)

function e()
	outputChatBox(" ",0,0,0,true) 
end

function onStart()
	car()
	e()
	outputChatBox("#ff9999Hello "..getPlayerName(localPlayer).." #ff9999, Merry Christmas :) .",0,0,0,true)
	e()
	outputChatBox("#ff9999To Enable / Disable The Christmas Infernus Skin , Please use the command #ff0000/xmas",0,0,0,true)
	e()
	outputChatBox("#ff9999 Note : This Mode Made By : #286699-DG|#Zea#990000D22",0,0,0,true)
	e()
end
addEventHandler("onClientResourceStart", resourceRoot, onStart)

And I recommend you not to copy-paste it, but to learn from it. If you don't understand why I did some piece of this code, just ask, we are here to help and you will not learn it, if we'll do complete code for you. I did it now only to show you, that outputChatBox is not only server-side function, also engineRestoreModel is the function you were looking for (to disable the Infernus skin).

Edited by Rataj
Link to comment

ik but when i did it client side there was problems i dont remember it so i decided to make server side 

btw thank you for your help the thing which i cant understand is 

addEventHandler("onClientResourceStart", resourceRoot, onStart)

what is that resourceRoot i cant understand why did you put it and didnt put getResourceRootElement(getThisResource()) and which words i can use

 

and what is the words which i can use here between that () in 

getPlayerName(localPlayer)

The code after i changed somethings (its working correctly now , thanks for help): 

----------------------  Made by ZeaD22 ----------------------

function e()
	outputChatBox("#ff9999--------------------------------------------",0,0,0,true)
end

function onStart()
	e()
	outputChatBox("#ff9999Hello "..getPlayerName(localPlayer).." #ff9999, Merry Christmas :) .",0,0,0,true)
	outputChatBox(" ",0,0,0,true)
	outputChatBox("#ff9999To Enable / Disable The Christmas Infernus Skin , Please use the command #ff0000/xmas",0,0,0,true)
	outputChatBox(" ",0,0,0,true)
	outputChatBox("#ff9999 Note : This Mode Made By : #286699-DG|#Zea#990000D22",0,0,0,true)
	e()
end
addEventHandler("onClientResourceStart", resourceRoot, onStart)

local replaced = false
	
function car()
	if replaced then
		engineRestoreModel(411)
		replaced = false
		e()
		outputChatBox("#ff9999You have Disabled The Christmas Infernus Skin",0,0,0,true)
		outputChatBox(" ",0,0,0,true)
		outputChatBox("#ff9999 Note : This Mode Made By : #286699-DG|#Zea#990000D22",0,0,0,true)
		e()
	else
		infernusTexture = engineLoadTXD("infernus.txd")
		engineImportTXD(infernusTexture, 411)
		infernusTexture = engineLoadDFF("infernus.dff", 411)
		engineReplaceModel(infernusTexture, 411)
		replaced = true
		e()
		outputChatBox("#ff9999Congratulations , You have Enabled The Christmas Infernus Skin",0,0,0,true)
		outputChatBox(" ",0,0,0,true)
		outputChatBox("#ff9999 Note : This Mode Made By : #286699-DG|#Zea#990000D22",0,0,0,true)
		e()
	end
end
addCommandHandler("xmas", car)

	
----------------------  Made by ZeaD22 ----------------------

 

Link to comment
18 hours ago, Rataj said:

No problem.

 

resourceRoot is same as getResourceRoot(getThisResource())

localPlayer is same as getLocalPlayer()

They are predefined variables by MTA.

More predefined variables can be found on MTA wiki: Predefined variables list

EPMhlp8lvCJxhwMtFDhFuk5P6lffE6cZTNxXT0tA   https://lh3.googleusercontent.com/EPMhlp8lvCJxhwMtFDhFuk5P6lffE6cZTNxXT0tAef1sx3Gr2b-3xNgsm7YgDfeIjaGS=s164

Edited by ZeaD22
Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...