-
Posts
253 -
Joined
-
Last visited
Everything posted by Miika
-
It works, but if I click "sign in" button, the camera does not stop moving. function hideLoginWindow() if (guiGetVisible(LoginPanel.window[1]) == true) then guiSetVisible(LoginPanel.window[1], false) showCursor(false) showChat(true) setCameraTarget ( getLocalPlayer() ) end if (guiGetVisible(LoginPanel.window[2]) == true) then guiSetVisible(LoginPanel.window[2], false) showCursor(false) showChat(true) setCameraTarget ( getLocalPlayer() ) end end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) local sm = {} sm.moov = 0 sm.object1,sm.object2 = nil,nil local function removeCamHandler() if(sm.moov == 1)then sm.moov = 0 end end local function camRender() if (sm.moov == 1) then local x1,y1,z1 = getElementPosition(sm.object1) local x2,y2,z2 = getElementPosition(sm.object2) setCameraMatrix(x1,y1,z1,x2,y2,z2) end end addEventHandler("onClientPreRender",root,camRender) function smoothMoveCamera(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time) if(sm.moov == 1)then return false end sm.object1 = createObject(1337,x1,y1,z1) sm.object2 = createObject(1337,x1t,y1t,z1t) setElementAlpha(sm.object1,0) setElementAlpha(sm.object2,0) setObjectScale(sm.object1,0.01) setObjectScale(sm.object2,0.01) moveObject(sm.object1,time,x2,y2,z2,0,0,0,"InOutQuad") moveObject(sm.object2,time,x2t,y2t,z2t,0,0,0,"InOutQuad") sm.moov = 1 setTimer(removeCamHandler,time,1) setTimer(destroyElement,time,1,sm.object1) setTimer(destroyElement,time,1,sm.object2) return true end function smoothMoveCamer() smoothMoveCamera(-1833.8863525391,155.25959777832,61.177501678467,-1834.4569091797,154.45721435547,61.00262451171,-1901.7043457031,488.02301025391,140.8975982666,-1901.7189941406,487.13961791992,140.4291839599,20000) end addEventHandler("onClientResourceStart", resourceRoot, smoothMoveCamer)
-
I tried many choices, none of which worked: x = -1833.8863525391 y = 155.25959777832 z = 61.177501678467 xl = -1834.4569091797 yl = 154.45721435547 zl = 61.00262451171 x2 = -1901.7043457031 y2 = 488.02301025391 z2 = 140.8975982666 z2l = -1901.7189941406 y2l = 487.13961791992 z2l = 140.4291839599 tim = 20000 function smoothMoveCamera(x, y, z, xl, yl, zl, x2, y2, z2, x2l, y2l, z2l, tim) end addEventHandler("onClientPreRender", root, smoothMoveCamera) x = -1833.8863525391 y = 155.25959777832 z = 61.177501678467 xl = -1834.4569091797 yl = 154.45721435547 zl = 61.00262451171 x2 = -1901.7043457031 y2 = 488.02301025391 z2 = 140.8975982666 z2l = -1901.7189941406 y2l = 487.13961791992 z2l = 140.4291839599 tim = 20000 function smoothMoveCamer() smoothMoveCamera(x, y, z, xl, yl, zl, x2, y2, z2, x2l, y2l, z2l, tim) end addEventHandler("onClientPreRender", root, smoothMoveCamer) function smoothMoveCamer() smoothMoveCamera(-1833.8863525391,155.25959777832,61.177501678467,-1834.4569091797,154.45721435547,61.00262451171,-1901.7043457031,488.02301025391,140.8975982666,-1901.7189941406,487.13961791992,140.4291839599,20000) end addEventHandler("onClientPreRender", root, smoothMoveCamer)
-
x = -1833.8863525391 y = 155.25959777832 z = 61.177501678467 xl = -1834.4569091797 yl = 154.45721435547 zl = 61.00262451171 x2 = -1901.7043457031 y2 = 488.02301025391 z2 = 140.8975982666 z2l = -1901.7189941406 y2l = 487.13961791992 z2l = 140.4291839599 tim = 20000 function smoothMoveCamera(x, y, z, xl, yl, zl, x2, y2, z2, x2l, y2l, z2l, tim) return true end addEventHandler("onClientResourceStart",root,smoothMoveCamera) Doesn't work and debugscript doesn't say anything
-
Yeah, but now I have problem with smoothMoveCamera ERROR: loginpanel\login_c.lua:208(in line 2 here) : attempt to call global 'smoothMoveCamera' (a nill value) function smoothMovCamera() smoothMoveCamera(-1833.8863525391,155.25959777832,61.177501678467,-1834.4569091797,154.45721435547,61.00262451171,-1901.7043457031,488.02301025391,140.8975982666,-1901.7189941406,487.13961791992,140.4291839599,20000) end addEventHandler("onClientPreRender",root,smoothMovCamera)
-
Oh, i put your code into register function ;D Now it works. Thx solidsnake!
-
Doesn't work
-
function saveLoginToXML(username, password) local xml_save = xmlLoadFile ("autologin.xml") if not xml_save then xml_save = xmlCreateFile("autologin.xml", "login") end if (username ~= "") then local xmlAccount = xmlFindChild (xml_save, "username", 0) if not xmlAccount then xmlAccount = xmlCreateChild(xml_save, "username") end xmlNodeSetValue (xmlAccount, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save) xmlUnloadFile (xml_save) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) I checked the file in my mta mods folder and it was saved the data
-
Hey! My login panel having a problem. It doesn't load data from xml file. The panel works perfectly, but xml not. btw, it saves data to xml, I checked it. No any errors in debugscript. [Clientside functions] [in main function] local username, password = loadDataFromXml() if not( username == "" or password == "") then guiCheckBoxSetSelected ( LoginPanel.checkbox[1], true ) guiSetText ( LoginPanel.edit[1], tostring(username)) guiSetText ( LoginPanel.edit[2], tostring(password)) else guiCheckBoxSetSelected ( LoginPanel.checkbox[1], false ) guiSetText ( LoginPanel.edit[1], tostring(username)) guiSetText ( LoginPanel.edit[2], tostring(password)) end [And load function] function loadDataFromXml() local xml_save = xmlLoadFile ("autologin.xml") if not xml_save then xml_save = xmlCreateFile("autologin.xml", "login") end local xmlAccount = xmlFindChild (xml_save, "username", 0) local passwordNode = xmlFindChild (xml_save, "password", 0) if xmlAccount and passwordNode then return xmlNodeGetValue(xmlAccount), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile ( xml_save ) end I do not show the full code, because I do not want someone to steal it: D What this might be the problem?
-
If you want to add jobs, you must be able to lua scripting. https://wiki.multitheftauto.com
-
Ideast to fix it?
-
Try this: addCommandHandler("createcar", function(thePlayer) local x,y,z = getElementPosition(thePlayer) veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,2,2,2,2) end ) addEventHandler("onVehicleEnter", getRootElement(), function(player) local theVehicle = getPedOccupiedVehicle ( player ) local id = getElementModel ( theVehicle ) if id == 422 then setVehicleWheelStates(theVehicle,-1,-1,-1,-1) outputChatBox('Wheel is fixed!', player, 0, 255, 0, true) end end)
-
ERROR: levelsystem/level_s.lua:23: Bad argument at @ 'getAccountData' [Expected account at arument 1, got nill ERROR: levelsystem/level_s.lua:24: Bad argument at @ 'getAccountData' [Expected account at arument 1, got nill function xpSystem(_, playerAccount) local lvl = getAccountData(playerAccount,"lvlsystem.currLevel") local xp = getAccountData(playerAccount,"lvlsystem.xp") if (playerAccount) then if lvl then else setAccountData(playerAccount,"lvlsystem.currLevel",0) end if xp then else setAccountData(playerAccount,"lvlsystem.xp",0) end end end addEventHandler("onPlayerLogin",getRootElement(),xpSystem) function convertXP () setTimer ( function(playeraccount) if ( playeraccount ) then outputChatBox("asd") local xp = getAccountData(playeraccount,"lvlsystem.xp") local currLevel = getAccountData (playeraccount, "lvlsystem.currLevel") triggerClientEvent ( source, "getLevel", source, "Level: " .. currLevel .. " xp: " .. xp .. "") local xp = getAccountData(playeraccount,"lvlsystem.xp") if xp then if (xp) < 1000 then elseif (xp) > 1000 then local xp = getAccountData (playeraccount, "lvlsystem.xp") local currLevel = getAccountData (playeraccount, "lvlsystem.currLevel") setAccountData(playeraccount,"lvlsystem.xp",xp - 1000) setAccountData(playeraccount,"lvlsystem.currLevel",currLevel + 1) -- level up message here -- end else setAccountData(playeraccount,"lvlsystem.xp",0) end end end, 2000, 1 ) end addEventHandler("onPlayerLogin",getRootElement(),convertXP) function checkLevelAndxp(thePlayer) local account = getPlayerAccount(thePlayer) if ( account ) then local level = getAccountData (account, "lvlsystem.currLevel") local xp = getAccountData (account, "lvlsystem.xp") outputChatBox("You have: " .. level .. " level and " .. xp .. " xp.", source, 0, 255, 0, true) end end addCommandHandler("myxp", checkLevelAndxp) function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) if ( killer ) and ( killer ~= source ) then local account = getPlayerAccount(killer) if (account) then local xp = getAccountData (account, "lvlsystem.xp") randomxp = math.random(50, 100) setAccountData(account,"lvlsystem.xp", xp + randomxp) end end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted )
-
you mean like this? end, 2000, 1, playeraccount ) Doesn't work
-
ERROR: levelsystem/level_s.lua:21: Bad argument at @ 'getAccountData' [Expected account at arument 1, got nill ERROR: levelsystem/level_s.lua:22: Bad argument at @ 'getAccountData' [Expected account at arument 1, got nill
-
I made the code again, and the next problem is: convertXP timer doesn't work. It does not update the client message. But /myxp works good. [server] function xpSystem(_, playerAccount) local lvl = getAccountData(playerAccount,"lvlsystem.currLevel") local xp = getAccountData(playerAccount,"lvlsystem.xp") if (playerAccount) then if lvl then else setAccountData(playerAccount,"lvlsystem.currLevel",0) end if xp then else setAccountData(playerAccount,"lvlsystem.xp",0) end end end addEventHandler("onPlayerLogin",getRootElement(),xpSystem) function convertXP (_, playeraccount) setTimer ( function(_, playeraccount) local xp = getAccountData(playeraccount,"lvlsystem.xp") local currLevel = getAccountData (playeraccount, "lvlsystem.currLevel") triggerClientEvent ( source, "getLevel", source, "Level: " .. currLevel .. " xp: " .. xp .. "") if ( playeraccount ) then local xp = getAccountData(playeraccount,"lvlsystem.xp") if xp then if (xp) < 1000 then elseif (xp) > 1000 then local currLevel = getAccountData (playeraccount, "lvlsystem.currLevel") setAccountData(playeraccount,"lvlsystem.xp",xp - 1000) setAccountData(playeraccount,"lvlsystem.currLevel",currLevel + 1) -- level up message here -- end else setAccountData(playeraccount,"lvlsystem.xp",0) end end local xp = getAccountData(playeraccount,"lvlsystem.xp") local currLevel = getAccountData (playeraccount, "lvlsystem.currLevel") triggerClientEvent ( source, "getLevel", source, "Level: " .. currLevel .. " xp: " .. xp .. "") end, 2000, 1 ) end addEventHandler("onPlayerLogin",getRootElement(),convertXP) function checkLevelAndxp(thePlayer) local account = getPlayerAccount(thePlayer) if ( account ) then local level = getAccountData (account, "lvlsystem.currLevel") local xp = getAccountData (account, "lvlsystem.xp") outputChatBox("You have: " .. level .. " level and " .. xp .. " xp.", source, 0, 255, 0, true) end end addCommandHandler("myxp", checkLevelAndxp) function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) if ( killer ) and ( killer ~= source ) then local account = getPlayerAccount(killer) if (account) then local xp = getAccountData (account, "lvlsystem.xp") randomxp = math.random(50, 100) setAccountData(account,"lvlsystem.xp", xp + randomxp) end end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) [Client] function playerJoin() setTimer ( checkLevel, 1000, 1) end addEventHandler("onClientResourceStart", getRootElement(), playerJoin) function addLevels() levelElement = guiCreateLabel ( 0.4, 0.02, 0.40, 0.40, "", true ) font = guiCreateFont( "font.ttf", 20 ) guiSetFont( levelElement, font ) guiLabelSetColor ( levelElement, 0, 180, 255 ) end addEventHandler("onClientResourceStart", getRootElement(), addLevels) function checkLevel( message ) setTimer ( checkLevel2, 1000, 1) guiSetText ( levelElement, "" .. message .. "" ) end addEvent( "getLevel", true ) addEventHandler( "getLevel", localPlayer, checkLevel ) function checkLevel2() setTimer ( checkLevel, 1000, 1) end
-
guy, I know it. But I want a solution.
-
[server] defaultlevel = 1 function LevelOnWasted ( ammo, killer, killerweapon, bodypart ) if ( killer ) and ( killer ~= source ) then if ( killer ) and ( killer ~= source ) then currentlevel = getElementData( killer, "levelsystem.currentlevel" ) if (currentlevel) == nil then setElementData ( killer, "levelsystem.currentlevel", defaultlevel ) setTimer(1000, 1, clientData) triggerClientEvent ( playerSource, "getLevel", playerSource, "" .. defaultlevel ) else addLevel = currentlevel + 1 setElementData ( killer, "levelsystem.currentlevel", addLevel ) setTimer(1000, 1, clientData) triggerClientEvent ( playerSource, "getLevel", playerSource, "" .. addLevel ) end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), LevelOnWasted) [Client] function playerJoin() setTimer ( checkLevel, 1000, 1) end addEventHandler("onClientResourceStart", getRootElement(), playerJoin) function addLevels() levelElement = guiCreateLabel ( 0.45, 0.02, 0.40, 0.40, "", true ) guiSetFont ( levelElement, "sa-gothic" ) guiLabelSetColor ( levelElement, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) end function checkLevel(level) setTimer ( checkLevel2, 1000, 1) guiSetText ( levelElement, "Level: ".. level ) end addEvent( "getLevel", true ) addEventHandler( "getLevel", localPlayer, checkLevel ) function checkLevel2() setTimer ( checkLevel, 1000, 1) end Now error is: ERROR: levelsystem/level_c.lua:14: attempt to concatenate global 'level' (a nill value)
-
ERROR: levelsystem/level_c.lua:16: attempt to concatenate global 'level' (a nill value)
-
I edit my code and next problem is: ERROR: levelsystem/level_s.lua:3: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nill] [server] defaultlevel = 1 function LevelOnWasted ( ammo, killer, killerweapon, bodypart ) local account = getPlayerAccount(client) if (account) and not isGuestAccount (account) then if ( killer ) and ( killer ~= source ) then currentlevel = getElementData( client, "levelsystem.currentlevel" ) if (currentlevel) == nil then setElementData ( client, "levelsystem.currentlevel", defaultlevel ) setTimer(1000, 1, clientData) triggerClientEvent ( playerSource, "getLevel", playerSource, "" .. defaultlevel ) else addLevel = currentlevel + 1 setElementData ( client, "levelsystem.currentlevel", addLevel ) setTimer(1000, 1, clientData) triggerClientEvent ( playerSource, "getLevel", playerSource, "" .. addLevel ) end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), LevelOnWasted)
-
Levelsystem doesn't work ERROR: levelsystem/level_s.lua:20: attempt to concatenate global 'currentLevel' (a nill value) ERROR: levelsystem/level_c.lua:16: attempt to concatenate global 'level' (a nill value) [Client] function playerJoin() setTimer ( checkLevel, 1000, 1) end addEventHandler("onClientResourceStart", getRootElement(), playerJoin) function addLevels(level) levelElement = guiCreateLabel ( 0.45, 0.02, 0.40, 0.40, "", true ) guiSetFont ( level, "sa-gothic" ) guiLabelSetColor ( level, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) end addEvent( "getLevel", true ) addEventHandler( "getLevel", localPlayer, addLevels ) function checkLevel() setTimer ( checkLevel2, 1000, 1) guiSetText ( levelElement, "Level: ".. level ) end function checkLevel2() setTimer ( checkLevel, 1000, 1) end [server] defaultlevel = 1 function LevelOnWasted ( ammo, killer, killerweapon, bodypart ) local account = getPlayerAccount(client) if (account) and not isGuestAccount (account) then if ( killer ) and ( killer ~= source ) then currentlevel = getElementData( client, "levelsystem.currentlevel" ) if (currentlevel) == nil then setElementData ( client, "levelsystem.currentlevel", defaultlevel ) setTimer(1000, 1, clientData) else addLevel = currentlevel + 1 setElementData ( client, "levelsystem.currentlevel", addLevel ) setTimer(1000, 1, clientData) end end end end function clientData() triggerClientEvent ( playerSource, "getLevel", playerSource, "" .. currentlevel ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), clientData) What is the problem?