PahanCS Posted October 25, 2010 Share Posted October 25, 2010 Please help with a script, something in him is not it! When I create a server, add your plug-in "Download Host Game-> Resources->(<)", loaded server, the console says that more than one plugin is loaded, it turns out my plugin loaded, no mistakes does not write, but it does not work. The essence of my plugin: After the death of a player to keep the skin and all the weapons to Spawn at all to give. When a player is connected if the player has a file Settings.xml, then plug loads of his skin and all the weapons, or creates the file, and if you disable saves in the file. Code plug-in: m_cSettings = nil m_iArraySkinid = {} m_iArrayWeaponsIds = {} m_iRootElement = getRootElement() outputConsole("[PahanCSScripts.lua Start]") function onPlayerJoinHandler() outputConsole("[onPlayerJoinHandler]") m_cSettings = xmlLoadFile("Settings.xml") if(m_cSettings == nil) then m_cSettings = xmlCreateFile ("Settings.xml", "Settings") xmlSaveFile(m_cSettings) return end m_iArraySkinid[source] = GetSettingInt(m_cSettings, "s") local i = 12 m_iArrayWeaponsIds[source] = {} while(i > 0) do table.insert(m_iArrayWeaponsIds[source], GetSettingInt(m_cSettings, i)) i = i - 1 end end function onPlayerQuitHandler() outputConsole("[onPlayerQuitHandler]") if(m_cSettings == nil) then m_cSettings = xmlLoadFile("Settings.xml") end if(m_cSettings == nil)) then m_cSettings = xmlCreateFile ("Settings.xml", "Settings") end if(m_iArraySkinid[source] == nil) then m_iArraySkinid[source] = 0 end SetSetting(m_cSettings, "s", m_iArraySkinid[source]) if (m_iArrayWeaponsIds[source] == nil) then xmlSaveFile(m_cSettings) xmlUnloadFile(m_cSettings) return else local i = 12 while(i > 0) do SetSetting(m_cSettings, i, m_iArrayWeaponsIds[source][i]) i = i - 1 end end xmlSaveFile(m_cSettings) xmlUnloadFile(m_cSettings) end function onPlayerSpawnHandler() outputConsole("[onPlayerSpawnHandler]") if(m_iArraySkinid[source] == nil) then m_iArraySkinid[source] = 0 end setElementModel(source, m_iArraySkinid[source]) if (m_iArrayWeaponsIds[source] == nil) then return end local i = 12 while(i > 0) do if m_iArrayWeaponsIds[source][i] > 0 and m_iArrayWeaponsIds[source][i] < 47 then giveWeapon(source, m_iArrayWeaponsIds[source][i], 999999999, false) end i = i - 1 end end function onPlayerWastedHandler() outputConsole("[onPlayerWastedHandler]") m_iArraySkinid[source] = getElementModel(source) local i = 12 m_iArrayWeaponsIds[source] = {} while(i > 0) do table.insert(m_iArrayWeaponsIds[source], getPlayerWeapon(source, i)) i = i - 1 end end function GetSettingInt(settings, setting) outputConsole("[GetSettingInt]") local result = xmlFindChild(settings, tostring(setting), 0) if(result) then return tonumber(xmlNodeGetValue(result)) else return 0 end end function SetSetting(settings, setting, value) outputConsole("[setSetting]") local node = xmlFindChild(settings, tostring( setting ), 0) if(node == nil)) then node = xmlCreateChild(settings, tostring(setting)) end xmlNodeSetValue(node,tostring(value)) xmlSaveFile(settings) end addEventHandler("OnPlayerQuit", m_iRootElement, onPlayerQuitHandler) addEventHandler("onPlayerJoin", m_iRootElement, onPlayerJoinHandler) addEventHandler("onPlayerSpawn", m_iRootElement, onPlayerSpawnHandler) addEventHandler("onPlayerWasted", m_iRootElement, onPlayerWastedHandler) Code meta.xml <meta> <info author="PahanCS" type="script" version="1.0.0" /> <script src="PahanCSScripts.lua" type="server" /> <script src="PahanCSScripts.lua" type="client" /> <config src="Settings.xml" type="server" /> <config src="Settings.xml" type="client" /> </meta> Link to comment
PahanCS Posted October 25, 2010 Author Share Posted October 25, 2010 Found an error, double parentheses: if(m_cSettings == nil[b]))[/b] then if(node == nil[b]))[/b] then Was the program "MTA Script Editor", it checks the syntax of the code. Now another error is not saved xml file "Settings.xml", why is not clear if anyone knows, please help. 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