-
Posts
367 -
Joined
-
Last visited
Everything posted by kieran
-
I had the exact same idea @koragg, decided just to get the text, then check if it's a number, and finally.... It works! now I just gotta make the server side stuff to set skins etc... Thanks for help, and if anyone is getting error with tonumber saying ) expected near =, then try ==
-
I made a gui for a skin shop, basically it is meant to check number from gridlist column and then use that for setElementModel, problem is that when I click it.... it gives this warning: WARNING:GUI's/clothes_c.lua:28: Bad argument @ 'setElementModel' [Expected element at argument 1, got string '1'] I also want to check players money, so I changed To But it then gave this error, ERROR: GUI's/clothes_c.lua:32: attempt to compare number with nil (Line 32 would be line 7) Thanks for any help!
-
@MIKI785 I can assure you I copied and pasted it with 0 edits last night, my only explanation is they updated that page today... Anyway thanks, it works great now!
-
Thank you @MIKI785... And that is straight from wiki, here is the link, look at example 2 and the code I started the topic here with... Apparently it needs changed.
-
Here is what I thought you meant... function createPlayerList () -- Create the grid list playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Online Players", 0.85 ) if ( column ) then -- If the column has been created, fill it with players for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end end addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList ) function click ( button, state, sx, sy, x, y, z, elem, gui ) -- if state is down ( not to trigger the function twice on mouse button up/down), clicked gui and the element is our player list if ( state == "down" ) and ( source == playerList ) then -- get the player name from the selected row, first column local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) outputChatBox ( playerName ) -- output it to chat box end end It should of worked in the first place, it was taken straight from wiki...
-
Still doesn't work @Gordon_G
-
I noticed guiGridListGetItemText on wiki, I put it on my server and gave it a go but it doesn't really output to chat like it says it will Example 2 on wiki function createPlayerList () -- Create the grid list playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create a players column in the list local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then -- If the column has been created, fill it with players for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false ) end addEventHandler ( "onClientGUIClick", playerList, click ) end end addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList ) function click ( button, state, sx, sy, x, y, z, elem, gui ) -- if state is down ( not to trigger the function twice on mouse button up/down), clicked gui and the element is our player list if ( ( state == "down" ) and ( gui == true ) and ( source == playerList ) ) then -- get the player name from the selected row, first column local playerName = guiGridListGetItemText ( playerList, guiGridListGetSelectedItem ( playerList ), 1 ) outputChatBox ( playerName ) -- output it to chat box end end Basically I am trying to use this as an example to teach myself how to use a similar system, the end result I am aiming for is using functions in that simple script to create a skin shop... Once I get it to actually do something I will try that, but for now I am trying simple stuff.
-
OMG thank you @Uknown. it woked perfectly
-
That permanently destroys the GUI when I press F1... WARNING:GUI\help.lua:10:Bad argument @ 'destroyElement' [Expected element at argument 1] That's my debugscript 3, I am not really experienced with stuff like for i = 1, #guiElements do local theElement = guiElements[ i ] destroyElement( theElement ) All I know is it basically groups it...
-
Okay, basically for now only way my GUI works is player logs in, it shows the GUI, then it checks visibility. The thing is I want to make it so my GUI doesn't have to come up for the script to notice an element is there.... Could I do this by simply binding a key to create gui or is it a little more complicated? Here's the current code (Yes I just kept it as is, easier than changing the original working script.) Server function HelpBinds() triggerClientEvent (source,"Help_Panel",getRootElement()) triggerClientEvent (source,"Help_Login",getRootElement()) end addEventHandler("onPlayerLogin", root, HelpBinds) Client local screenW, screenH = guiGetScreenSize() function ShowHelp() guiSetInputEnabled(false) showCursor(true) helpWindow = guiCreateWindow((screenW - 591) / 2, (screenH - 534) / 2, 591, 534, "Information", false) guiWindowSetSizable(helpWindow, false) guiSetAlpha(helpWindow, 0.92) guiSetProperty(helpWindow, "CaptionColour", "FFD7E21C") CloseInfo = guiCreateLabel(230, 499, 196, 35, "F1 to close window", false, helpWindow) guiSetProperty(CloseInfo, "NormalTextColour", "FFFE0000") helphelpTabsPan = guiCreateTabPanel(9, 28, 572, 461, false, helpWindow) helpTabs = guiCreateTab("Tab1", helphelpTabsPan) memo = guiCreateMemo(6, 32, 561, 399, "Line 1. \n\nLine 2.", false, helpTabs) label = guiCreateLabel(13, 10, 544, 26, "Label", false, helpTabs) guiLabelSetColor(label, 255, 100, 25) helpTabs2 = guiCreateTab("Tab2", helphelpTabsPan) memo2 = guiCreateMemo(5, 32, 561, 399, "Line 1 \n/Line 2", false, helpTabs2) label2 = guiCreateLabel(15, 10, 544, 26, "Label", false, helpTabs2) guiLabelSetColor(label2, 255, 100, 25) helpTabs3 = guiCreateTab("Tab3", helphelpTabsPan) memo3 = guiCreateMemo(5, 32, 561, 399, "Line 1.\nLine2.", false, helpTabs3) end addEvent("Help_Login", true) addEventHandler("Help_Login", getRootElement(), ShowHelp) function DestroyGUI() if ( guiGetVisible ( helpWindow ) == false ) then guiSetVisible ( helpWindow, true ) showCursor(true) else guiSetVisible ( helpWindow, false ) showCursor(false) end end function binds() bindKey("f1", "down", DestroyGUI) end addEvent("Help_Panel", true) addEventHandler("Help_Panel", getRootElement(), binds) This works perfect, no problems in the code. But if you test this and remove the event "Help_Login" you will see my issue... It doesn't think a GUI is there, how can you keep a GUI closed for user but still bind it's window to a key?
-
Thanks @kikos500..... But I wanted it so you didn't have to show GUI to get it visible I'll figure it out haha
-
Omg I feel so stupid ? I was thinking I needed to make event on it but wasn't too sure, thanks! I done it that way because I used GUI editor, it is easier for me as I can just check top to see if I made typos etc. Also buttons tab is so I my list buttons as I have various binds, I was just struggling to bind GUI's, this is the second one I done, so still learning. Sorry for quoting, on tablet and it doesn't like mentions
-
@kikos500 Nope, doesn't work.... Also the GUI was perfectly fine..... I was just wanting to bind a key to the function when player logged in and then check if the gui was visible, close it, else I wanted to open it.....
-
I made a simple gui for information etc, trying to bind the F1 key to the gui... Worked fine when I just tried onClientResourceStart and done nothing with key binds, but no debug errors, so I can't see where I gone wrong. helpTabs = {} helphelpTabsPan = {} helpLabel = {} helpButton = {} helpWindow = {} helpMemo = {} --helpState is false. helpState = false function ShowHelp(key, keyState) --Checking if "helpState" is true. if ( keyState == "down" ) and helpState == true then guiSetVisible(helpWindow, false) destroyElement(helpWindow) helpWindow = nil showCursor(false) else if helpState == false then guiSetInputEnabled(false) showCursor(true) --Random GUI crap. local screenW, screenH = guiGetScreenSize() helpWindow = guiCreateWindow((screenW - 591) / 2, (screenH - 534) / 2, 591, 534, "Information", false) guiWindowSetSizable(helpWindow, false) guiSetAlpha(helpWindow, 0.92) guiSetProperty(helpWindow, "CaptionColour", "FFD7E21C") helpButton = guiCreateButton(485, 489, 96, 35, "Close", false, helpWindow) guiSetProperty(helpButton, "NormalTextColour", "FFFE0000") helphelpTabsPan = guiCreateTabPanel(9, 28, 572, 461, false, helpWindow) helpTabs = guiCreateTab("Rules", helphelpTabsPan) memo = guiCreateMemo(6, 32, 561, 399, "Text goes here.", false, helpTabs) label = guiCreateLabel(13, 10, 544, 26, "Label text goes here.", false, helpTabs) guiLabelSetColor(label, 255, 100, 25) helpTabs2 = guiCreateTab("Commands", helphelpTabsPan) memo2 = guiCreateMemo(5, 32, 561, 399, "Text goes here.", false, helpTabs2) label2 = guiCreateLabel(15, 10, 544, 26, "Label text goes here.", false, helpTabs2) guiLabelSetColor(label2, 255, 100, 25) helpTabs3 = guiCreateTab("Buttons", helphelpTabsPan) memo3 = guiCreateMemo(5, 32, 561, 399, "Text goes here.", false, helpTabs3) helpState = true addEventHandler("onClientGUIClick", helpButton,onClickCloseBut) end end end --This closes it, but am I setting "helpState" correctly? function onClickCloseBut(button,state) if(button == "left" and state == "up") then if (source == helpButton) then guiSetVisible(helpWindow, false) destroyElement(helpWindow) helpWindow = nil showCursor(false) helpState = false end end end --KEY BIND. function bindTheKeys () bindKey ( "F1", "down", ShowHelp ) end addEventHandler("onClientPlayerJoin", getRootElement(), bindTheKeys ) Basically this is a lot to read, so top part before guiGetScreenSize and after the GUI stuff is probably where the problem is.... It is obvious but I have never tried binding keys to client before. Thanks for help!
-
I'd say setAccountData..... But that is the same, are you looking to use this on a login script?
-
my bad @pro-mos, I meant line 42, I forgot I had stuff at start. (Is commented, so won't matter if it's there.) never mind, I put local where local shouldn't be... Fixed that problem.... But now I have another problem: Weather.lua:23: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] Starting to think it would just be easier to set the data and timers client side.....
-
I made a super simple weather script that changes weather and rain, but I am having some issues as I want to add a command to allow players to stop rain until they log off.... Server weather = {} weathers = 3 --1,2,3 weather[1] = 0 weather[2] = 3 weather[3] = 7 --rain rain = {} Therain = 3 --1,2,3 rain[1] = 0 rain[2] = 10 rain[3] = 5 setTimer( function (thePlayer) local Wacc = getPlayerAccount(thePlayer) if Wacc then local CheckWeather = getElementData( thePlayer, "tempdata.ChkWeath" ) if ( CheckWeather == false ) then randomWeather = math.random (1, weathers) randomRain = math.random (1, Therain) local cusweather = setWeather (weather[randomWeather]) local cusrain = setRainLevel (rain[randomRain]) elseif ( CheckWeather == true ) then return end end end, 300000, 1) function stopTheRain ( thePlayer, command ) local Wacc = getPlayerAccount(thePlayer) if Wacc then local setElementData ( thePlayer, "tempdata.ChkWeath", Wacc ) end end addCommandHandler("norain", stopTheRain) Basically it works on server if it's just cycling weather, but I wanted players to have choice for it to never rain as it can be a little FPS consuming. Error: [2017-07-13 03:02:19] SCRIPT ERROR: WeatherStuff\Weather.lua:63: ')' expected near ',' Why does it expect a bracket on line 63? Oh! And while I'm at it... Am I even setting element data correctly? Thanks in advance! P.S Reason it is server is because I tried it client (just changing weather and rain level (set for 10 secs) ) and it didn't work.
-
Can you not use setTimer? It might work as you could time each function or maybe even the whole script to save.... I have played a couple servers with auto save and believe they use a similar method. (You may want to freeze players while there is a save as it can cause lags)
- 1 reply
-
- 1
-
Hello, I am wondering if anybody knows where I can find the reefer skin everyone has these days, or any giant cargo ship skin! Would make it myself but apparently my ancient PC doesn't support 3d max! Basically I am looking for a huge boat with any texture (wood preferred) and lots of space so I can attach a few crates on the front.
-
I am a very bad scripter.... But you have 2 of the same file, one is server, and one client. Try replacing the meta with this. <meta> <script src="bug.lua" type="client" /> </meta>
-
Thanks @pa3ck Needed that you're right, not thinking it out, should make plan then use wiki to find stuff..... Otherwise I'll get nowhere.
-
Haha, I'll try bud... the data is not the problem though it's warping player to vehicle, as it is a server function I am trying to be "smart" and use triggerServerEvent to trigger the warp.... I am very inexperienced
-
I found out that is not my biggest problem.... The trailers are so easy :3 not too worried about syncing.... The problem NOW is that blips show for all players! Oh... And also the truck doesn't want to warp ped in (I know, is server side function, why I put it in server) basically the bare bones of what I'm trying to achieve are above if you wanna help make it feel free, but I have also had another idea for trailers.... From another server I used to play at I know it is possible to attach that flat trailer you get for trains (forget the name)...It seems there were no bugs with that somehow. Anyway, thing I really want is to get it actually warping ped into vehicle and only showing stuff to player that hits marker, as opposed to showing blips etc to every player. P.S. This is basically a script I will build on once working and I understand it a bit better, I plan to make numerous jobs in the future such as captain and arms/drugs delivery, basically warping a player into vehicle, spawning marker and blip for the player, then when player hits marker he gets cash sum.
-
so you want to make GUI button invisible?
-
It is not actually my script, It was made by MoPoMaN and he used it server side, I made a similar script before.... But I had many problems with blips and markers showing for all players, this is why I want to make this script client side, after I will give it to him. You can find his script here. I know is 3 years old.... But loads of servers want a good script, even if it's just to use as a skeleton for there own script Basically the idea is when player hits marker, truck spawns with trailer, removes marker client side so other players may take the job, and then when player hits the delivery marker his trailer gets destroyed, which then triggers client side event to put marker to spawn truck from again.... So rather basic script. As I say, MoPoMaN's script. If you want I will PM you some other ideas I had for scripts.