-
Posts
696 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Dzsozi (h03)
-
I would like to do it with the 1st option, and I know that I have to save the xp and level as well, but I would like to do it this way. The only problem is that I don't know how, I fail at the math part of it, I don't know how to get the numbers that I wrote before. Could you help me with this please?
-
Well, while I was waiting for answers I came up with a new idea, that might be easier to make and more simple. I started doing that but I am having issues. Here's the current script: local TPLimit = 5000 function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil; if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower(); if name_:find(name, 1, true) then return player; end end end end function givePlayerTP(thePlayer, tp) if (thePlayer) then if (tonumber(tp) > 0) then setElementData(thePlayer, "playertp", (getElementData(thePlayer, "playertp") or 0) + tp); if (getElementData(thePlayer, "playertp") >= TPLimit) then setElementData(thePlayer, "playerlevel", (getElementData(thePlayer, "playerlevel") or 1) + 1); setElementData(thePlayer, "playertp", 0); outputChatBox("level up", thePlayer); outputChatBox(getElementData(thePlayer, "playerlevel"), thePlayer); end end end end function setPlayerTP(thePlayer, tp) if (thePlayer) then if (tonumber(tp) >= 0) then setElementData(thePlayer, "playertp", tp); if (getElementData(thePlayer, "playertp") >= TPLimit) then setElementData(thePlayer, "playerlevel", (getElementData(thePlayer, "playerlevel") or 1) + 1); setElementData(thePlayer, "playertp", 0) outputChatBox("level up", thePlayer); outputChatBox(getElementData(thePlayer, "playerlevel"), thePlayer); end end end end function getPlayerTP(thePlayer) if (thePlayer) then return getElementData(thePlayer, "playertp") or 0; end end addCommandHandler("settp", function(playerSource, commandName, targetPlayer, tp) local target = getPlayerFromPartialName(targetPlayer); if not tonumber(tp) or not target then outputChatBox("/"..commandName.." [játékos] [pont]", playerSource); else if (tonumber(tp) >= 0) then setPlayerTP(target, tp); outputChatBox(getPlayerTP(target).." TP", target); else outputChatBox("0-nak vagy annál többnek kell lennie", playerSource); end end end); addCommandHandler("givetp", function(playerSource, commandName, targetPlayer, tp) local target = getPlayerFromPartialName(targetPlayer); if not tonumber(tp) or not target then outputChatBox("/"..commandName.." [játékos] [pont]", playerSource); else if (tonumber(tp) > 0) then givePlayerTP(target, tp); outputChatBox(getPlayerTP(target).." TP", target); else outputChatBox("többnek kell lennie mint 0", playerSource); end end end); addCommandHandler("gettp", function(playerSource) local points = getPlayerTP(playerSource); outputChatBox(points, playerSource); end); I would like to make it work like the following: If I reach 5000 XP then my XP gets reseted to 0 and I will get a new level, so I am at level 1, I get 5000 XP and then I will be level 2, this part works fine. I have 2 problems with maths, one of them is when I get more XP than the limit, for example 5001, then how can I get the plus 1 XP and level 2? The other problem is, if I get for example 27500 XP then I should get +5 levels, so I would be level 6 and I should get 2500 XP. If I divide 27500 with 5000 (so the TPLimit) then I should get 5,5 and I should give myself 5 levels and multiple the amount of XP that I need with 0.5, but I don't know how to "split" this number, or how to do that whole thing, so I will always get mathematically perfect numbers for levels and XP. Could somebody help me please?
-
Isn't it possible to make it without tables? Because I want to make it unlimited (I didn't try the script yet).
-
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
You didn't change anything. -
I am having problems again, now with handling the level up. Could somebody help me please? local TPLimit = 5000; function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil; if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower(); if name_:find(name, 1, true) then return player; end end end end function givePlayerTP(thePlayer, tp) if (thePlayer) then if (tonumber(tp) > 0) then setElementData(thePlayer, "playertp", (getElementData(thePlayer, "playertp") or 0) + tp); if (tonumber(getElementData(thePlayer, "playertp")) >= tonumber(TPLimit)) then --Level up. --TPLimit = TPLimit + TPLimit setElementData(thePlayer, "playerlevel", (getElementData(thePlayer, "playerlevel") or 0) + 1); outputChatBox("level up", thePlayer) outputChatBox("" .. getElementData(thePlayer, "playerlevel") .. "", thePlayer) end end end end function setPlayerTP(thePlayer, tp) if (thePlayer) then if (tonumber(tp) >= 0) then setElementData(thePlayer, "playertp", tp); if (tonumber(getElementData(thePlayer, "playertp")) >= tonumber(TPLimit)) then --Level up. --TPLimit = TPLimit + TPLimit setElementData(thePlayer, "playerlevel", (getElementData(thePlayer, "playerlevel") or 0) + 1); outputChatBox("level up", thePlayer) outputChatBox("" .. getElementData(thePlayer, "playerlevel") .. "", thePlayer) end end end end function getPlayerTP(thePlayer) if (thePlayer) then return getElementData(thePlayer, "playertp") or 0; end end addCommandHandler("settp", function(playerSource, commandName, targetPlayer, tp) local target = getPlayerFromPartialName(targetPlayer); -- way better that the built in MTA function! if not tonumber(tp) or not target then outputChatBox("/" .. commandName .. " [játékos] [pont]", playerSource); else if (tonumber(tp) >= 0) then setPlayerTP(target, tp); outputChatBox("" .. getPlayerTP(target) .. " TP", target); else outputChatBox("0-nak vagy annál többnek kell lennie", playerSource); end end end); addCommandHandler("givetp", function(playerSource, commandName, targetPlayer, tp) local target = getPlayerFromPartialName(targetPlayer); -- way better that the built in MTA function! if not tonumber(tp) or not target then outputChatBox("/" .. commandName .. " [játékos] [pont]", playerSource); else if (tonumber(tp) > 0) then givePlayerTP(target, tp); outputChatBox("" .. getPlayerTP(target) .. " TP", target); else outputChatBox("többnek kell lennie mint 0", playerSource); end end end); addCommandHandler("gettp", function(playerSource) local points = getPlayerTP(playerSource); outputChatBox("" .. points .. "", playerSource); end); If I reach 5000 XP then I get leveled up, as it would be normal, but if I get for example 1 XP after I reached 5000 I get leveled up again. So if I have more XP than 5000, no matter how much, I get leveled up everytime when I get XP. I would like to make it work like if you level up then the amount of XP needed for the next level will get added again, like I already wrote down, if you are level 1 then you need 5000 XP, if you reach 5000 XP then you will be level 2 and you need 10000 XP for level 3, etc. How can I make it work like this? Do I have to make other functions for giving a level to the player? How can I make it possible?
-
It works I guess, thank you very much! I will try to continue and save it, thank you again! I will write if I have any problems.
-
Alright, I will do that, but I am having issues again, not it doesn't output anything, if I write in /gettp I don't get any message, or if I write in /givetp dzsozi 5 then it doesn't output the amount of TP I have, so I guess it also doesn't even give me the TP. local TPLimit = 5000 local playerTP = 0 local playerLevel = 0 --[[addEvent("onPlayerLevelUp", true) addEventHandler("onPlayerLevelUp", root, function(thePlayer) if thePlayer == source then local if playerTP end end)]] function givePlayerTP(thePlayer, tp) if (isElement(thePlayer)) then if (tp > 0) then --playerTP = playerTP + tp setElementData(thePlayer, "playertp", (getElementData(thePlayer, "playertp") or 0) + tp); end end end function getPlayerTP(thePlayer) if (isElement(thePlayer)) then return getElementData(thePlayer, "playertp") --playerTP end end function setPlayerTP(thePlayer, tp) if (isElement(thePlayer)) then if (tp > 0) then playerTP = tp end end end function giveTP(playerSource, commandName, targetPlayer, tp) local target = getPlayerFromName(targetPlayer) if not tonumber(tp) or not tostring(target) then outputChatBox("/" .. commandName .. " [játékos] [pont]", playerSource) else if tonumber(tp) > 0 then givePlayerTP(target, tp) outputChatBox("" .. getPlayerTP(target) .. " TP", target) else outputChatBox("többnek kell lennie mint 0", playerSource) end end end addCommandHandler("givetp", giveTP) function getTP(playerSource) local points = getPlayerTP(playerSource) outputChatBox("" .. points .. "", playerSource) end addCommandHandler("gettp", getTP) What could be the problem?
-
I think I will go with element datas, I think it's easier, thank you, I will try it! And how can I make the event, to detect if a player leveled up and then duplicate the tplimit and give him a higher level?
-
So instead of playerTP = playerTP + tp I should use setElementData(thePlayer, "playerTP", playerTP + tp)?
-
Hello! I would like to create a custom level system for my server, that works something like GTA V's level system, a little bit different maybe. There would be a limit for a level, so for example 5000 XP is 1 level, if you reach 5000 XP then you level up, after you leveled up another 5000 XP is getting added to the limit, so at level 2 you would need 10000 XP, level 3 15000 XP, level 4 20000 XP etc. etc. I would like to make this thing without tables, because I would like it to be unlimited. I started to make it and firstly I wanted to make the basic commands, like giving getting and setting XP for players, but I bumped into some problems that I can't fix. I would like to ask for help for these things: - How can I make an event handler which detects if a player leveled up? So I could make functions like playing a sound on each level up, or showing a screen that shows my new level and stuff, etc., so I would have an "onClientPlayerLevelUp" and an "onPlayerLevelUp" (for client and server) - How can I fix the current issue, which is the following: the script doesn't give me the amount of XP I write in, if I write in wrong parameters it shows me the error messages, but if I write it in correctly it doesn't give me the XP, only shows 0 XP in chat. Could somebody help me with these two things please? I would highly appreciate it! Here's the server side script: local TPLimit = 5000 local playerTP = 0 local playerLevel = 0 --[[addEvent("onPlayerLevelUp", true) addEventHandler("onPlayerLevelUp", root, function(thePlayer) if thePlayer == source then local if playerTP > TPLimit then -- I DONT KNOW WHAT TO PUT HERE OR HOW TO MAKE THIS EVENT end end)]] function givePlayerTP(thePlayer, tp) if (isElement(thePlayer)) then if (tp > 0) then playerTP = playerTP + tp end end end function getPlayerTP(thePlayer) if (isElement(thePlayer)) then return playerTP else return 0 end end function setPlayerTP(thePlayer, tp) if (isElement(thePlayer)) then if (tp > 0) then playerTP = tp end end end function giveTP(playerSource, commandName, targetPlayer, tp) local target = getPlayerFromName(targetPlayer) if not tonumber(tp) or not tostring(target) then outputChatBox("/" .. commandName .. " [player] [xp]", playerSource) else if tonumber(tp) > 0 then givePlayerTP(target, tp) outputChatBox("" .. getPlayerTP(target) .. " XP") else outputChatBox("must be more than 0", playerSource) end end end addCommandHandler("givetp", giveTP) function getTP(playerSource) local points = getPlayerTP(playerSource) outputChatBox("" .. points .. "", playerSource) end addCommandHandler("gettp", getTP) I'm not sure what's wrong and what's not in this script, I created it by myself but I can't figure out how to fix these two things I mentioned. I would like to make it function like I wrote above, and I would also like to save it somehow, I was thinking about element datas and account datas, maybe I will stick to account datas so I can save it with my current save system, which is similar like the community ones (gets all the data that needs to be saved from the player on quit and then sets the account data to it, when you login it gets the saved account data and sets your stats position, etc. to the saved one, hope you know that or understand me). Thank you for your response and help in advance! P.S.: Also, how I could make client and server side exports for giving XP? Because I would like to make it work like if you do missions or stunts or something like that you will get for example 1500 XP for a mission, or is it enough if I make an export for the server side? Should it be only server sided and then trigger it from the server side to client side in the mission scripts?
-
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Did you find anything you could help me with? Could you fix it? Any "news"? -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Okay, thank you very much! -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
I want the weapon images to switch when I scroll the mouse wheel, and if I press left click the weapon I scrolled the mousewheel on to, gets equipped, also I would like to skip unused weapon slots so I don't have to scroll through every weapon slot. -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Bump -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Can't figure it out how could I fix it, somebody help me please! -
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Okay, thanks, I will try that, and what about the images? Is there any way to fix it? -
Bump.
- 18 replies
-
Could somebody help me with a weapon selector and dx functions?
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Bump. -
Hello ! I can't manage to get my weapon selector to work and some dx functions. I would like to create a custom weapon selector hud that would look like this (I created this image in photoshop): And it would work like this: If you scroll your mouse wheel upwards it would change the middle (equipped/current) weapon picture (in this case ak-47) to the next weapon, the upper weapon picture (in this case the shotgun) to your current/equipped weapon and if you press left click it would switch to that weapon. So when you scroll the mouse wheel up or down it would change between the weapon icons and if you press left click it would switch to the weapon you scrolled to. I can't manage to fix the icon changing, it doesn't change the icons when I scroll the wheel, only the ammo text updates. The other problem is that I have to scroll through every weapon slots even if I have only 1 or 2 weapons (except weapon slot 0, the fist) for example. So I could skip the empty weapon slots. Could somebody help me with this please? I would be so grateful! Here's a download link for the resource: https://www.mediafire.com/?pdi3sdw1o64iu2l
-
Bump.
- 18 replies
-
[QUESTION] Get the next and previous weapon
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
I think it works, I will try to do finish what I wanted to do, thank you very much!! -
I changed the wordWarping limit to 50 instead of 20 and set the outputchatbox colorcodes to true, I added a red colorcode in front of "but" and added back the white colorcode in front of "it". So, the line breaks after the "math" word, and its only red until the math word, so after the line break the color doesn't continue. Is there any way to fix that? If so, that would work perfectly!
- 18 replies
-
[QUESTION] Get the next and previous weapon
Dzsozi (h03) replied to Dzsozi (h03)'s topic in Scripting
Oh and one more thing I forgot: How can I get the ammo of the next and the previous weapons? -
Hello, I would like to make a custom weapon switching screen with dx functions and I would like to display the current weapon, the previous weapon and the next weapon after the current. My question is how I can make that possible and how can I draw these 3 weapons with dx? I would like to make the script work like if you hold a button a panel appears and if you scroll you scroll to the next weapon, but you can see the weapon you had before on the previous slot. It's kinda hard to explain in words, but take a look at the gif I made: Hope you know now what I mean. So how can I do that? Is this possible?
-
Okay, so I would like to go back to the VCS PS2 convertion and try to have it as the map, VCS's map is also even better, looks better at some points, has different models for example the ferris wheel in downtown, etc. and scene2res didn't output any error when I started the convertion so I GUESS it has all the models and ipl/ide files correctly. I linked a gtaforums.com topic, and there is a download link for the map with blank collisions and there is one more link for normal (?) collisions. Since I don't really understand this whole thing, how these things really work, I would like to know what blank collisions mean? My guess is that basically it is a collision file without collision. Am I right or not? If I am right, then - here comes the second question - how can I make them real, "normal" collisions? Or how can I make it work, I mean, there is the download link for the collision files, but there are 16 .col files, some of them contain lots of collisions (I checked it with collision file editor II) and some of them contains 1 or 2 collisions, but they are all named col and a number after it. So, how can I assign these real collisions to the .dff models, even if they don't have the same file name? I just don't understand this whole thing, I would really appreciate if someone could give me in-depth instructions for achieving Vice City as a map resource for MTA. BTW I could make Vice City into MTA, kind of half way, because there were lots of errors about missing models and unknown definitions, and in-game lots of buildings were flickering or missing, or there was a SA object, but the collisions and textures were fine.