Jump to content

Sorata_Kanda

Members
  • Posts

    76
  • Joined

  • Last visited

Everything posted by Sorata_Kanda

  1. Hey everyone, as you can read the title, I need a little help with callbacks on passwordVerify On the wiki, it says it is recommended to use a callback function in order to avoid freezes. But how can I determine inside of my callback function whether passwordVerify returns the hash or false? Does it work like this? local function passwordVerifyCB(var) if var then outputDebugString("The password has been verified.") else outputDebugString("The password couldn't be verified.") end end passwordVerify("test", --[[Some random hash]], {}, passwordVerifyCB) Thanks in advance.
  2. Today has been an update which adds clearChatBox Update your client/server and try it again.
  3. Look up addEventHandler("onWeaponFire", ...) Normally, when you cancel the event, you shouldn't be able to damage players.
  4. I tried the script and it's working. You cannot see the colshape unless you have development mode activated and use the client-sided commandsh showcol Add this to a client script and activate development mode. Then type /showcol 1 and go to the position of your collision shape. addCommandHandler("devmode", function(source) if getDevelopmentMode then setDevelopmentMode(false) outputChatBox("Development mode deactivated") else setDevelopmentMode(true) outputChatBox("Development mode activated") end end) EDIT: Don't forget to declare this <min_mta_version server="1.5.4-9.11305" client="1.1.1-9.03355" /> in your meta.xml as setDevelopmentMode won't work then.
  5. Please check, if your safezone is even created or not. I'll try your script as soon as I'm back at home. if safezone then outputDebugScript("Safezone was created.") else outputDebugScript("Safezone could not be created.") end
  6. Your parameters for createColRectangle are wrong. You have to delete a number.
  7. local safezone = createColRectangle (22,22,22,20,30) --this is just a random number.. setElementDimension( safezone, 3 ) -- Dimension is 3, you can use another number aswell. local Radar = createRadarArea ( 790.6, -1120.1,50,50,r, g, b, alpha) addEventHandler ( "onColShapeHit", safezone, function (thePlayer,matchingDimension ) if matchingDimension and isElement(thePlayer) and getElementType(thePlayer) == "player" then toggleControl ( thePlayer, "fire",false ) end end) addEventHandler ( "onColShapeLeave", safezone, function ( thePlayer, matchingDimension ) if matchingDimension and isElement(thePlayer) and getElementType(thePlayer) == "player" then toggleControl ( thePlayer, "fire", true ) end end)
  8. Post can be deleted. I created a mysql table where I store a 'template' for the teams. Then, when the resource starts, it grabs the data from the table, creates the teams and stores them into a local table (lua).
  9. Check if your server is running the version which is required for clearChatBox Also, try using it client-sided. Something that I also thought about is that you have to set the minimum version of your server in order to use the new functions. But I'm not sure, this is just an assumption.
  10. Hello everyone, what is the best way to store a team in MySQL databases? I don't even know if it's possible as creating teams through a resource doesn't make them permanent. Thanks in advance!
  11. Topic can be closed now. Issue was in a other script file which has a pre-created label that might have blocked me from using the GUI.
  12. function vehiclepaint(player,seat) if (seat == 0) then if (getPlayerTeam(player)) then local r,g,b = getTeamColor(getPlayerTeam(player)) -- Das hier holt die Farbe des Teams setVehicleColor(source,r,g,b,r,g,b,r,g,b,r,g,b) -- Das hier übernimmt die Farbe des Teams auf das Auto setPlayerNametagColor(player, r,g,b) else setVehicleColor(source,255,255,255,255,255,255,255,255,255,255,255,255) setPlayerNametagColor(player, 255,255,255) end end end Du müsstest entweder diese Funktion verändern, oder du entfernst sie. Vergiss nicht, wenn du die Funktion entfernst, dass du auch überall vehiclepaint() entfernst. Oder du machst das einfach so: function vehiclepaint(player,seat) if (seat == 0) then setVehicleColor(source,255,255,255,255,255,255,255,255,255,255,255,255) setPlayerNametagColor(player, 255,255,255) end end
  13. That issue's fixed too by simply adding get/setElementData. Still curious why it is created twice and not once. Now there's a focusing problem. When I click outside the GUI, I can't use it anymore. But when I start guieditor and then open that ped GUI, I can move it and re-focus it just fine.
  14. Okay, I managed to fix the issue. There was an invisible GUI blocking the screen. However, when I click on the ped, the GUI opens twice. And when I click outside of the GUI, I can't focus them anymore.
  15. Hey everyone, whenever I start my resource, I'm not able to click on any GUI buttons, nor on the Admin, nor can I bring up the GUI through "onClientClick". What I want to do is to make a GUI appear whenever I click on a certain ped. These peds are listed in the .map file as well. -- This is client-sided -- Ped godmode local bsGirls = { getElementByID("burgershotGirl"), getElementByID("burgershotDowntownGirl"), getElementByID("burgershotJuniperGirl") } function noDamage() cancelEvent() end function addGodmode() for k, v in ipairs(bsGirls) do addEventHandler( "onClientPedDamage", v, noDamage ) end end addGodmode() GUIRestaurants = { button = {}, window = {}, label = {} } function createGUI() GUIRestaurants.window[1] = guiCreateWindow(475, 259, 350, 208, "Burger Shot - Order", false) guiWindowSetSizable(GUIRestaurants.window[1], false) GUIRestaurants.label[1] = guiCreateLabel(28, 22, 294, 47, "Welcome to Burger Shot!\nChoose one of our delicious meals.", false, GUIRestaurants.window[1]) guiLabelSetHorizontalAlign(GUIRestaurants.label[1], "center", false) guiLabelSetVerticalAlign(GUIRestaurants.label[1], "center") GUIRestaurants.button[1] = guiCreateButton(17, 84, 143, 36, "Heart Stopper\n$50", false, GUIRestaurants.window[1]) GUIRestaurants.button[2] = guiCreateButton(17, 130, 143, 36, "Money Shot Deal\n$45", false, GUIRestaurants.window[1]) GUIRestaurants.button[3] = guiCreateButton(189, 84, 143, 36, "Bleeder Meel\n$25", false, GUIRestaurants.window[1]) GUIRestaurants.button[4] = guiCreateButton(189, 130, 143, 36, "Low Key Salad\n$20", false, GUIRestaurants.window[1]) GUIRestaurants.button[5] = guiCreateButton(101, 178, 149, 20, "Close", false, GUIRestaurants.window[1]) -- Close button addEventHandler("onClientGUIClick", GUIRestaurants.button[5], function() showCursor(false) destroyElement(GUIRestaurants) end, false) -- Heart Stopper addEventHandler( "onClientGUIClick", GUIRestaurants.button[1], function() if payPrice( 50 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 45) else outputChatBox("You don't have enough money.") end end, false) -- Money Shot Deal addEventHandler( "onClientGUIClick", GUIRestaurants.button[2], function() if payPrice( 45 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 35) else outputChatBox("You don't have enough money.") end end, false) -- Bleeder Meel addEventHandler( "onClientGUIClick", GUIRestaurants.button[3], function() if payPrice( 25 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 25) else outputChatBox("You don't have enough money.") end end, false) -- Low Key Salad addEventHandler( "onClientGUIClick", GUIRestaurants.button[4], function() if payPrice( 20 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 15) else outputChatBox("You don't have enough money.") end end, false) end function openGUI( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) outputDebugString("Yes") if clickedElement then outputDebugString("Yes") for k, v in ipairs(bsGirls) do if clickedElement == v then createGUI() end end end end addEventHandler("onClientClick", getRootElement(), openGUI) function payPrice( price ) local money = getPlayerMoney() if money < price then return false else local newMoney = money - price setPlayerMoney(newMoney) return true end end As you can also see in function openGUI() I added outputDebugString("") but nothing is even put out. What did I do wrong? Thanks in advance.
  16. I'll try that one. But I don't know if you understand the problem or not. Take this picture as an example: I would expect "onMarketHit" to trigger only when you really enter the marker. Instead, it happens only when your nearby. I suspect it's related with the type of marker. I'll try the corona one.
  17. I actually set the coordinates so you don't tp into the marker. What's strange is that it even triggers onMarkerHit when you are nearby of the marker and not when you "only" hit the marker.
  18. Why? 'burgershotEnter' and 'burgershotExit' are elements. The table 'burgershotSpawn' contains coordinates where the player are supposed to be teleported when they hit the marker respectively.
  19. So something I've examined is that there's a certain detection range which goes beyond the marker itself. Can you specifically set that range?
  20. Hey everyone, again, I have a problem. I want to teleport the player whenever it hits the entry/exit marker of a Burger Shot. However, whenever I add the functions to the "onMarkerHit" event, I keep teleporting back and forth. Script is server-sided. --Entry/Exit marker grabbed from .map file local burgershotEnter = getElementByID("burgershotEnter") local burgershotExit = getElementByID("burgershotExit") -- Table of spawn location when entering/leaving Burger Shot local burgershotSpawn = { enter = { x = 364.4189453125, y = -74.154296875, z = 1001.5078125, rot = 313.42001342773 }, exit = { x = -2334.7392578125, y = -166.7958984375, z = 35.5546875, rot = 221.95193481445 } } -- Debug stuff whether coordinates of entry/exit markers are the same as defined in .map (which in this case, it is) local enterPosX, enterPosY, enterPosZ = getElementPosition(burgershotEnter) local exitPosX, exitPosY, exitPosZ = getElementPosition(burgershotExit) outputChatBox ( "Enter: " .. tostring(burgershotEnter) .. " " .. enterPosX .. ", " .. enterPosY .. ", " .. enterPosZ ) outputChatBox ( "Exit: " .. tostring(burgershotExit) .. " " .. exitPosX .. ", " .. exitPosY .. ", " .. exitPosZ ) --------------------------------------- function burgershotEnterHit( player ) outputChatBox("Welcome to Burger Shot! If you want to order something, click on the ped.") setElementInterior( player, 10, burgershotSpawn["enter"]["x"], burgershotSpawn["enter"]["y"], burgershotSpawn["enter"]["z"]) --setPlayerRotation( burgershotSpawn["enter"]["rot"] ) end function burgershotExitHit( player ) outputChatBox("Thanks for visiting Burger Shot! Come again soon!") setElementInterior( player, 0, burgershotSpawn["exit"]["x"], burgershotSpawn["exit"]["y"], burgershotSpawn["exit"]["z"]) --setPlayerRotation( burgershotSpawn["exit"]["rot"] ) end addEventHandler( "onMarkerHit", burgershotEnter, burgershotEnterHit ) addEventHandler( "onMarkerHit", burgershotExit, burgershotExitHit ) Do I still have to check if the player is in the marker or not? Because I thought I don't need to do that when I tie the function to an event with the according marker. Thanks in advance!
  21. Wow. Didn't expect that it would make such a difference. Well, I guess I'll try to do it this way and that way. Thank you very much for your responses!
  22. Let's take a MySQL script with function() _query as an example. If I follow the OOP approach, then it would be a little bit messy because then I would have to create a new MySQL object for each script which would result in multiple connections. So I don't know how I can use the functions of the MySQL script in other scripts without doing OOP.
  23. Hello everyone, I'm sort of new to MTA scripting and thus a beginner to Lua. I have programmed in Java before where I prefered trying to stay on OOP. I just found out that it's also possible to do that in Lua, but it looks kind of confusing to me. Moreover, it's a feature that was introduced in MTA 1.4 which seems not too long ago. That's why I want to ask you what kind of programming you would prefer? OOP or procedural programming? Thank you in advance!
  24. Ah, dang. Sorry for that. Thank you very much!
×
×
  • Create New...