
Remp
Members-
Posts
210 -
Joined
-
Last visited
Everything posted by Remp
-
make sure you add the command handler after you define the function (ie., below)
-
you are adding the command handler inside the function, so the command handler is never created (because the function is never called) just move the command handler outside of the guihelp function
-
i actually have /grab bound to my jump key already and id argue that being forced to use specific keys (either changed and therefore unknown between servers or not) is more obtrusive having said that, if its an issue you can easily comment the command handlers and add your own bind lines jumping again to drop can be a problem when people spam jump to get on, only to find they pressed it one too many times and dropped off again
-
new version uploaded, this fixes a bug with destroying helis while hanging, improves overall robustness of code and adds 3 new exported functions: - IsPlayerHangingFromHeli(player) - returns true is they are, false if they arent. nil if player is invalid - GetPlayerHangingData(player) - returns heli,side,line_percent,legs_up if they are hanging, nil if they arent or an invalid player is passed - GetPlayersHangingFromHeli(heli, [side, line]) - returns a table of all players hanging on the heli, nil if there are no players or the heli is invalid
-
are you using the latest version (2.0)? A bug introduced in mta 1.0 blocks all previous guieditor versions from generating any output if you are, do you get any output in the print window? (right click -> print code)
-
if we look at the wiki page for guiGetText we can see this for the return values: Returns a string containing the requested element's text, or false if the gui element passed to the function is invalid. so this must mean that you are passing an invalid gui element make sure cstFieldRd, cstFieldGrn and cstFieldBlu all exist (or that you havent just mistyped the variable names)
-
Ive updated the resource to work around the bug introduced in 1.0 that stops the guieditor generating any output, if you do not update, the editor will not work with mta 1.0 this is not an ideal solution and will be reverted as soon as the bug within mta is fixed, if you find any more bugs stemming from this please tell me
-
When you create a tabpanel with the editor it automatically adds 1 tab to the panel. this is done because tabpanels alone dont trigger onClientMouseEnter/Exit (but tabpanels with tabs do), so we cannot tell when the cursor is on them and consequently cannot draw the appropriate right click menu, leaving you with a blank tabpanel that you cant add anything to, modify or remove (this is also why you cant set the variable name of a tabpanel, among other things) Ive got no idea why the first tab doesnt actually show up in the editor, ive looked at it before and suspect its a timing bug but if i try to hack around it i risk creating more problems coincidentally, MTA also wont allow you to create tabpanels without tabs. if you do so it will just add a blank tab, so the best advice i can give you is that you use a blank gridlist instead of a tabpanel to create a background element
-
according to the wiki only png is supported, you cannot use jpg
-
creating gui outside a function is very temperamental and generally not a good idea, moving your gui and your onClientGUIClick event handler into an onClientResourceStart handle should sort this out (assuming there are no errors with your button code, eg: MainBgdImg exists)
-
when the player joins the server (onPlayerJoin triggers) they havent necessarily finished downloading the clientside scripts, so you may end up trying to trigger a client event that simply does not exist yet you can use onClientResourceStart clientside to achieve what you are trying to do, it is triggered when the player finishes downloading the client script when they join the server function CreateGUI() outputChatBox ( "The CreateGUI function fired", 255, 255, 255 ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),CreateGUI)
-
What do you mean by not well? it worked fine for me during testing (though i have a modified parachute resource). There is very little i can do about this really as its the responsibilty of the parachute resource itself, if you can find exact steps to invoke a notably bad response from it you could report it
-
In your original code the gui will be recreated every time you show it, id suggest moving the gui creation code into "onStart" so its only created once (when you join the server) and changing your "Window" function to just show/hide it To have it show when a player dies, use the event onClientPlayerWasted to call a function that shows the gui Your new code would then be: Window = {} Button = {} function Window() if guiGetVisible(Window[1]) then guiSetVisible(Window[1],false) showCursor(false) else guiSetVisible(Window[1],true) showCursor(true) end end addCommandHandler("spawnpoint",changeWindow) function onStart() Window[1] = guiCreateWindow(300,173,250,350,"Finland RPG Spawnpoints",false) Button[1] = guiCreateButton(0.061728395521641,0.10330578684807,0.85185188055038,0.10743801295757,"Home",true,Window[1]) Button[2] = guiCreateButton(0.061728395521641,0.23553718626499,0.85185188055038,0.10743801295757,"Grove. St",true,Window[1]) Button[3] = guiCreateButton(0.061728395521641,0.37190082669258,0.85185188055038,0.10743801295757,"Pirate Ship",true,Window[1]) Button[4] = guiCreateButton(0.061728395521641,0.50413221120834,0.85185188055038,0.10743801295757,"Jefferson",true,Window[1]) Button[5] = guiCreateButton(0.061728395521641,0.63636362552643,0.85185188055038,0.10743801295757,"Wang Cars",true,Window[1]) Button[6] = guiCreateButton(0.055555555969477,0.77272725105286,0.85802471637726,0.16528925299644,"Close Menu",true,Window[1]) guiWindowSetSizable ( Window[1], false ) addEventHandler ( "onClientGUIClick", Button[1], Warp ) addEventHandler ( "onClientGUIClick", Button[2], Warp ) addEventHandler ( "onClientGUIClick", Button[3], Warp ) addEventHandler ( "onClientGUIClick", Button[4], Warp ) addEventHandler ( "onClientGUIClick", Button[5], Warp ) addEventHandler ( "onClientGUIClick", Button[6], close ) guiSetVisible(Window[1],true) showCursor(true) bindKey ("F4", "down", changeWindow ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onStart) function playerWasted() -- if the local player died (ie: you died) if source == getLocalPlayer() then -- show the window guiSetVisible(Window[1],true) showCursor(true) end end addEventHandler("onClientPlayerWasted",getRootElement(),playerWasted)
-
you've already added the onClientGUIClick event handler, so first you need to create your "Warp" function. You can check the source in the warp function to see which button was pressed and set spawn coordinates accordingly You will then need to use triggerServerEvent() to tell the server where and when to spawn, and then create a function serverside to spawn the player Your code should look something like this: Clientside function Warp(button,state) -- when they click with the left mouse button if button == "left" and state == "down" then -- if they clicked the home button if source == Button[1] then -- change 0,0,0 here to the Home coordinates triggerServerEvent("SpawnPlayerFromGUI",getLocalPlayer(),0,0,0) -- if they clicked the Grove. St button elseif source == Button[2] then -- change 0,0,0 here to the Grove. St coordinates triggerServerEvent("SpawnPlayerFromGUI",getLocalPlayer(),0,0,0) -- if they clicked the Pirate Ship button elseif source == Button[3] then -- change 0,0,0 here to the Pirate Ship coordinates triggerServerEvent("SpawnPlayerFromGUI",getLocalPlayer(),0,0,0) -- etc end end end Serverside function spawnThePlayer(x,y,z) -- spawn the player at the specified coordinates spawnPlayer(source,x,y,z) end -- add the event, this will be triggered when you click the gui addEvent("SpawnPlayerFromGUI",true) -- call the function spawnThePlayer when the event is triggered addEventHandler("SpawnPlayerFromGUI",getRootElement(),spawnThePlayer) This is just example code so you will need to fill in the areas that are unfinished and tweak it to your exact needs If there is anything in there you dont understand i suggest reading the relavent wiki page for that function and make sure you are familiar with scripting GUI
-
This is a resource for the nightly/1.0 build allowing players to jump, grab and hang onto parts of helicopters By default, to grab a helicopter use the command /grab (or your jump key) when close to it, use /drop (or backspace) to drop off These can be bound to keys with mta's bind command: /bind (eg: "/bind lshift down grab") (type "bind" into the console ingame to see the required syntax) You can set the commands/binds used to grab and drop through the settings in the meta.xml You will be automatically dropped from the heli if it gets close to the ground or your player collides with another element I strongly advise you to not bind your enter_exit or enter_passenger keys to /grab or /drop as this can cause some very disruptive problems Exported functions: - toggleHangingWeightLimit(true/false) - this toggles the hanging weight limit on or off, defaults to on (meaning there are limits to how many people each helicopter can have hanging from it at a time, each helicopter is different) - setPlayerGrabState(player, true/false, [ heli , side = "right", line_percent = 0.5]) - this forces the player hanging on (true) or off (false) a helicopter. Using this to hang players will bypass the hanging weight limit for that helicopter, there are also no suitability checks done so it is up to you to make sure the player can actually start hanging (ie: isnt attached to something, isnt dead, etc). side indicates which side of the heli the player will hang onto, line_percent indicates how far along the grab lines the player will be hanging (0 for front, 1 for back) - isPlayerGrabbingHeli(player) - returns true if they are, false if they arent. nil if player is invalid - getPlayerGrabData(player) - returns heli,side,line_percent,legs_up if they are hanging, nil if they arent or an invalid player is passed - getPlayersGrabbingHeli(heli, [side, line]) - returns a table of all players hanging on the heli, nil if there are no players or the heli is invalid Example videos: Download: https://community.multitheftauto.com/index.php?p= ... ils&id=357 Known issues: - occasionally the animation wont loop properly and the player will not swing, they will just hang in a static position - using the same key as enter_exit / enter_passenger for grabbing can cause you to not be able to walk forward until you jump, be stuck in water unable to jump until you swim to land again or unable to get in/out of vehicles - using the same key as enter_exit for dropping causes you to jack the driver of water vehicles if you drop while they are parked on the water (due to the entry warping)
-
you misspelled guiGetVisible in the changeState function, and you also placed the closing bracket in the wrong place, it should be guiSetVisible(Window[1],false) not guiSetVisible(Window[1]),false your function names in the onClientGUIClick handlers cannot contain spaces, so "full health" will be invalid and should be changed to something without spaces (such as fullhealth or full_health) you will probably also want to create your gui in your onStart function, currently you will recreate the gui every time you want to show it which is not ideal try this code: Window = {} Button = {} function changeState( ) if guiGetVisible(Window[1]) then guiSetVisible(Window[1],false) showCursor(false) else guiSetVisible(Window[1],true) showCursor(true) end end addCommandHandler("cp",changeState) function onStart() Window[1] = guiCreateWindow(618,138,512,595,"Player Menu",false) Button[1] = guiCreateButton(0.7348,0.3395,0.2551,0.0627,"Fix Vehicle $200",true,Window[1]) Button[2] = guiCreateButton(0.7368,0.4225,0.2551,0.0627,"Full Health $200",true,Window[1]) Button[3] = guiCreateButton(0.7368,0.5074,0.2551,0.0627,"Suicide",true,Window[1]) Button[4] = guiCreateButton(0.6883,0.8764,0.2895,0.0978,"Close",true,Window[1]) guiSetFont(Button[4],"sa-header") Label[1] = guiCreateLabel(0.004,0.0018,0.6761,0.0886,"Killingzone RPG",true,Window[1]) guiLabelSetColor(Label[1],255,255,255) guiLabelSetVerticalAlign(Label[1],"top") guiLabelSetHorizontalAlign(Label[1],"left",false) guiSetFont(Label[1],"sa-header") Label[2] = guiCreateLabel(0.7571,0.6605,0.1356,0.0332,"Your Health",true,Window[1]) guiLabelSetColor(Label[2],255,255,255) guiLabelSetVerticalAlign(Label[2],"top") guiLabelSetHorizontalAlign(Label[2],"left",false) Label[3] = guiCreateLabel(0.753,0.7528,0.1559,0.0314,"Vehicle Health",true,Window[1]) guiLabelSetColor(Label[3],255,255,255) guiLabelSetVerticalAlign(Label[3],"top") guiLabelSetHorizontalAlign(Label[3],"left",false) Progress[1] = guiCreateProgressBar(0.6356,0.6919,0.3563,0.0406,true,Window[1]) Progress[2] = guiCreateProgressBar(0.6356,0.7786,0.3603,0.048,true,Window[1]) Memo[1]= guiCreateMemo(0.0385,0.1236,0.5668,0.2804,"Hello and Welcome to Killingzone RPG.\n\nIn this server you can buy house, cars, and even weapons.\n\nOwner:\n[NRNS]Coolboy\n\nScripters:\n[NRNS]Coolboy\n**ArmGuy**G",true,Window[1]) guiMemoSetReadOnly(Memo[1],true) Memo[2] = guiCreateMemo(0.0466,0.4539,0.5648,0.3598,"Rules:\n\nThere is no hacking in this server you will be banned.\n\nRespeact other players.\n",true,Window[1]) guiMemoSetReadOnly(Memo[2],true) guiWindowSetSizable(Window[1],false) guiSetVisible(Window[1],false) addEventHandler ( "onClientGUIClick", Button[1], fixvehicle) addEventHandler ( "onClientGUIClick", Button[2], fullhealth) addEventHandler ( "onClientGUIClick", Button[3], suicide ) addEventHandler ( "onClientGUIClick", Button[4], close ) bindKey ("m", "down", changeState ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onStart) function close(button,state) if button == "left" and state =="down" then if guiGetVisible(Window[1]) then guiSetVisible(Window[1],false) showCursor(false) end end end remember to always double check for spelling errors in your code as these are very common causes of problems
-
hey guys can you help my script gui is not working {help
Remp replied to gordliamjack's topic in Scripting
onResourceStart does not exist clientside, use onClientResourceStart -
the guieditor will only create the usable gui code for you, it wont actually implement it on your server You need to find the resource file you want to edit and put the code (from guieditor_output.txt) into it, if you're unsure how to do this i suggest reading some of the documentation available on the wiki: Introduction to Scripting, Introduction to Scripting GUI
-
is your script client side? (as defined in your meta.xml)
-
use addEventHandler (http://development.mtasa.com/index.php? ... entHandler) and onClientGUIClick (http://development.mtasa.com/index.php? ... ntGUIClick) for example, this code calls the function "ClickedButton" and will output a message to the chat when you click on the button "GUIEditor_Button[2]": function ClickedButton() outputChatBox("You clicked the button.") end addEventHandler("onClientGUIClick",GUIEditor_Button[2],ClickedButton,false) You can then put whatever code you want in the function (such as for spawning vehicles) Also, your variable "car healt" is invalid and will error. Variable names cannot have spaces in, replace it with an underscore or compact it to a single word (eg: car_health or carhealth)
-
addEventHandler("onClientMouseWheel",getRootElement(),function(direction) if source==yourbutton then -- up if direction==1 then yourvariable = yourvariable + 1 outputChatBox("Variable increased by one, new value: "..yourvariable) -- down elseif direction==-1 then yourvariable = yourvariable - 1 outputChatBox("Variable decreased by one, new value: "..yourvariable) end end end)
-
the variable theVehicle doesnt exist in setDataOnStart, use value (when you loop through a table using ipairs the second variable you define [value] will be the element from the table [in this case the vehicle element] and the first [key] will be the index) function setDataOnStart ( ) for key, value in ipairs(getElementsByType("vehicle")) do local blockState = getElementData ( value, "engine.block" ) if ( blockState ) == false or ( blockState ) == nil then setElementData ( value, "engine.block", 100 ) end local battState = getElementData ( value, "engine.battery" ) ...
-
you made a typo here ... tabCops = guiCreateTab("Cops",tbpCharSelect) tabCivs = guiCreateTab("Civilians",tpbCharSelect) tabArmy = guiCreateTab("Army",tpbCharSelect) ... you put tpbCharSelect instead of tbpCharSelect for the second and third tabs
-
new version uploaded based on Hoss212's report that fixes an issue with quotes inside strings https://community.multitheftauto.com/index.html?p ... ils&id=141
-
Ive never had any problems with larger GUIs. could you give me a more detailed explanation of what it is you're trying to make (which elements and which order) and your variable naming style? are you loading an existing GUI? are you using any of the "extra" options? do you get any errors (either in the chat or in debugscript)?