Jump to content

pa3ck

Members
  • Posts

    1,141
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by pa3ck

  1. The variable "current" is always the last item in the table, because that's the last element in the loop. You need a way to store the details in each marker. Simply use setElementData(marker, "markerID", idInTheTable) and then you can retrieve the information using the table index.
  2. You are keep creating posts and asking "what's wrong?, what's wrong?", but you should be the one telling us what's wrong. Please take your time and look at it YOURSELF, don't expect us to fix everything in your code, that's just not gonna happen. So please, use"/debugscript 3" and debug your code yourself and if you can't fix it, come back here with the error. That's how programmers ask for help. Don't take this as an insult, but I mean you can spot the errors right away (not closing the end or function) and debugscript 3 will even tell you them...
  3. I know, but you don't need the loop, if you don't specify the sendTo element it will be triggered to every player, MTA does the loop for you.
  4. Whats the loop for? triggerClientEvent( "onServerSynced", root, text ) --> same thing...
  5. I don't know what changes you made to the code, but probably the weaps["curr"] is empty when you are trying to get the next and prev weapon. I already told you what to do, initialize the "curr" to the current BEFORE drawing anything. You don't need to use getWeaponIDFromName, you never even touch the weapon names in the code, the reason why it's string is because that's the default value in the table. For your other problem change this: if weaps["curr"] == weaps["old"] then to this: if weaps["curr"] == getPedWeapon(localPlayer) then so when you give yourself a weapon, the highlight will change accordingly.
  6. It is in plain English. Anyone who can read would know that the resource is dependent on CIThelp but it's not running.
  7. No, you can't do any sort of GUI on server side. You have to use onClientDebugMessage and store the messages in an array then use dxDrawText to draw it on the screen, but you might be better of downloading something like this from the community, to be honest.
  8. It did work for me actually, I was only getting warnings that it might not work in the future version because of the negative value. Anyway, because you changed the code and you draw the render when the Q is pressed and not the way I did it (when you mouse wheel up-down) you have to define the current weapon. Put this snippet in the Q function, where you start drawing the render (where you have the addEventHandler.onClientRender..) if weaps["curr"] == 0 then weaps["old"] = getPedWeapon(localPlayer) weaps["curr"] = weaps["old"] end
  9. I was messing around with it, it works, but sometimes I was getting warnings in the getNextWeapon function, just look into it yourself, somehow a value goes in as negative, but if you test it, you will see the warning yourself. Link: http://pastebin.com/X1WbCirE
  10. You obviously need the http port to send http data you're welcome
  11. Which port are you trying to ping? HTTP or server port?
  12. I don't really have time to look at the actual code side, I'm currently lost in the .NET world, however, I made a little diagram about what you have to do. You already have the nextWeapon and previousWeapon functions, that's good but you'll have to tweak it so you can actually specify the current weapon and get the next and previous weapon relative to that. Look at this diagram, I always make diagrams like this, helps you visualize the problem: Hope it helps.
  13. Yes, you can do it with onClientElementDataChange or just trigger client and serverside whenever a users gets experience and is leveled up, but if you want to go with the element date change: addEventHandler("onClientElementDataChange", root, function(data, oldLevel) if source == localPlayer and oldLevel and data == "playerlevel" then local currLevel = getElementData(localPlayer, "playerlevel") if currLevel > oldLevel then triggerEvent("onClientLevelUp", localPlayer) -- this one triggers client side event, player element will be the source triggerServerEvent("onLevelUp", localPlayer) -- this one is server side, player element will be the variable 'client' end end end)
  14. You're welcome. Try this client-side: addEventHandler("onClientElementDataChange", root, function(data, oldLevel) if source == localPlayer and oldLevel and data == "playerlevel" then local currLevel = getElementData(localPlayer, "playerlevel") if currLevel > oldLevel then outputChatBox("szintet leptel") end end end)
  15. This should work: function givePlayerTP(thePlayer, tp) if (thePlayer) then if (tonumber(tp) > 0) then local currExp = getElementData(thePlayer, "playertp") or 0 local currLvl = getElementData(thePlayer, "playerlevel") or 0 local newTempExp = currExp + tp local newTempLevel = math.floor(newTempExp / TPLimit) local newExp = newTempExp - newTempLevel * TPLimit local newLevel = currLvl + newTempLevel setElementData(thePlayer, "playerlevel", newLevel); setElementData(thePlayer, "playertp", newExp); if (newLevel > currLvl) then outputChatBox("level up", thePlayer); end end end end
  16. That's because thePlayer is not defined in your code function openMyGate2 ( thePlayer, cmd ) local playerTeam = getPlayerTeam(thePlayer) local teamElement = getTeamFromName("#000000Psycho Ma#990000ns Gang") if playerTeam and playerTeam == teamElement then moveObject ( myGate2, 10184, -1631.6999511719,688.20001220703,13) setTimer ( movingMyGateBack2, 5000, 1 ) else outputChatBox("You are not on the right team") end end addCommandHandler("polgarage",openMyGate2)
  17. Replace your setPlayerTP function with this and see what happens when you do setPlayerTP(playerElement, 5001): function setPlayerTP(thePlayer, tp) if (thePlayer) then if (tonumber(tp) >= 0) then local newLevel = math.floor(tp / TPLimit) local newExp = tp % TPLimit setElementData(thePlayer, "playertp", newExp); setElementData(thePlayer, "playerlevel", newLevel); outputChatBox("Megvaltozott a szinted, uj szint: " .. newLevel .. ", uj exp: " .. newExp, thePlayer); end end end
  18. There are 2 ways doing it in terms of saving the players' stats: 1st. Save the current level and current XP (between 0-5000) and whenever they level up reset the XP to 0. If you are proceeding with this option, you have to calculate the level from the current experience and save that in MySQL or SQLite along with the current experience (between 0 - 5000) 2nd: Only save the XP and not resetting it at level up (I just provided the exact code for calculating the level from XP). So let's say, you have 23000 XP you are able to calculate the current level, next level and also the exp needed to level up. If you are proceeding with this option, you only need to save the current experience, look at this code and try it yourself, you should be able to finish your script with my code: local expLimit = 5000 local currentExpLevel = 20050 local currentExp = currentExpLevel % expLimit -- use modulus to get the current exp local currentLevel = math.floor(currentExpLevel / expLimit ) -- round down the current exp divided by the expLimit, which gets the current level local nextLevel = math.ceil(currentExpLevel / expLimit ) -- round up to get the next level if nextLevel == currentLevel then nextLevel = nextLevel + 1 end -- evenly divides, so next level and current level is the same, fix that by incrementing the next level local neededNextLevel = expLimit - currentExp -- we already know the current exp (between 0-5000), we can subtract that from the exp limit to get the exp needed to level up outputChatBox ( "Current EXP: " .. currentExp ) outputChatBox ( "Current levelL " .. currentLevel ) outputChatBox ( "Your next level: " .. nextLevel ) outputChatBox ( "Needed for next level: " .. neededNextLevel )
  19. pa3ck

    Sneak

    You also closed the script tag right after opening it.
  20. Of course it is possible, use something like this: local tpLimit = 5000 local currTp = 5001 local nextLevel = math.ceil(currTp / tpLimit) -- round up local currLevel = math.floor(currTp / tpLimit) -- round down if(nextLevel == currLevel) then -- just leveled up and it divides into tpLimit evenly nextLevel = nextLevel + 1 end print("Current level: " .. currLevel .. ", next level: " .. nextLevel)
  21. @line 77 you have syntax error, wrong use of anonymous function. Use '/debugscript 3' to spot errors like this. Also, if you want to get the players team, you'll need to use getPlayerTeam
×
×
  • Create New...