Duoclsnake Posted August 10, 2011 Posted August 10, 2011 https://community.multitheftauto.com/ind ... ls&id=1253 after I downloaded and started it with the command / start but it does not work when I type / level one can not help my instructions Thanks] local rootElement = getRootElement() levels = {} levels[0] = {"Test 0", "10"} levels[1] = {"Test 1", "20"} levels[2] = {"Test 2", "100"} levels[3] = {"Test 3", "150"} levels[4] = {"Test 4", "200"} function ResourceStart () executeSQLCreateTable("levels", "accountname STRING, level INT") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ResourceStart) function addPlayer() local account = getPlayerAccount(source) local playername = getPlayerName(source) CheckPlayer = executeSQLSelect ( "levels", "accountname", "accountname = '" .. getAccountName(account) .. "'" ) if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then executeSQLInsert ( "levels", "'".. getAccountName(account) .."','0'" ) end end addEventHandler("onPlayerLogin",rootElement,addPlayer) addEventHandler( "onElementDataChange", rootElement, function () if getElementType(source) == "player" then local acc = getPlayerAccount(source) local accountname = getAccountName(acc) local playername = getPlayerName(source) local data = getElementData(source,"exp") local sqldata = executeSQLSelect ( "levels", "level","accountname = '" .. accountname .. "'") lvl = sqldata[1]["level"] if tostring(data) == tostring(levels[lvl][2]) then outputChatBox("*Level system: congratulations ".. playername .." you're now a ".. levels[lvl][1] .."!",getRootElement(),0,255,0) local textDis = textCreateDisplay () local item = textCreateTextItem( "LEVEL UP! YOU'RE NOW LEVEL ".. tostring(sqldata[1]["level"]), 0.5, 0.4, 2, 0, 255, 0, 255, 4, "center", "center" ) textDisplayAddText ( textDis, item ) textDisplayAddObserver ( textDis, source ) setTimer ( textDestroyTextItem, 5000, 1, item ) setTimer ( textDestroyDisplay, 5000, 1, textDis ) sql = tonumber(sqldata[1]["level"]) + 1 executeSQLUpdate("levels", "level = '".. sql .."'", "accountname = '".. accountname .."'") end end end)
Duoclsnake Posted August 10, 2011 Author Posted August 10, 2011 There is no commands at all in the script. so if I want to do level 10 then I tried / admins but no level
JR10 Posted August 10, 2011 Posted August 10, 2011 There is NO Commands in the whole script Add this to the script: addCommandHandler("exp", function(player,cmd,exp) if not tonumber(exp) then return end setElementData(player, "exp", tonumber(exp)) end) Try: /exp 10 You will be level 1
Duoclsnake Posted August 10, 2011 Author Posted August 10, 2011 There is NO Commands in the whole script Add this to the script: addCommandHandler("exp", function(player,cmd,exp) if not tonumber(exp) then return end setElementData(player, "exp", tonumber(exp)) end) Try: /exp 10 You will be level 1 Thanks
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