ZeaD22 Posted December 25, 2016 Share Posted December 25, 2016 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
ZeaD22 Posted December 26, 2016 Author Share Posted December 26, 2016 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
ViRuZGamiing Posted December 26, 2016 Share Posted December 26, 2016 46 minutes ago, ZeaD22 said: isnt there any help for this ??? getPlayerName(source) returns false, which means source isn't a player That being because the event is onResourceStart Quoting wiki's onResourceStart: Source The source of this event is the root element in the resource that started. source = the resource started (this isn't the player) 1 Link to comment
ZeaD22 Posted December 26, 2016 Author Share Posted December 26, 2016 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
Rataj Posted December 26, 2016 Share Posted December 26, 2016 (edited) 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 December 26, 2016 by Rataj Link to comment
ZeaD22 Posted December 26, 2016 Author Share Posted December 26, 2016 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
Rataj Posted December 26, 2016 Share Posted December 26, 2016 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 Link to comment
ZeaD22 Posted December 27, 2016 Author Share Posted December 27, 2016 (edited) 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 https://lh3.googleusercontent.com/EPMhlp8lvCJxhwMtFDhFuk5P6lffE6cZTNxXT0tAef1sx3Gr2b-3xNgsm7YgDfeIjaGS=s164 Edited December 27, 2016 by ZeaD22 Link to comment
ZeaD22 Posted December 27, 2016 Author Share Posted December 27, 2016 lol i can't open the wiki Link to comment
myonlake Posted December 27, 2016 Share Posted December 27, 2016 9 hours ago, ZeaD22 said: lol i can't open the wiki The Wiki is down at the moment, try again later. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now