Jump to content

Gtagasje

Members
  • Posts

    141
  • Joined

  • Last visited

Everything posted by Gtagasje

  1. Gtagasje

    Picture :D

    getPlayersInPhotograph()
  2. Gtagasje

    Edit boxes

    Well this turned into a little argument. Thanks anyways, I guess I'll have to work my way around it using labels or something.
  3. Gtagasje

    Edit boxes

    Hi, just a simple question. Is there a way to set the edit box alpha to 0, but still show the text? Or does that have to be done by some other gui element? I want users to be able to fill it in though.
  4. Works perfect, thank you very much.
  5. It still only loads the first one. EDIT: I might've found the problem, I think it creates them all at 1 place, since I get the gui 3 times when I hit the marker. Do you know how to fix this? if (result) then if type(result) == "table" then for i, v in ipairs(result) do local id = tonumber(result[1]["id"]) local x = tonumber(result[1]["x"]) local y = tonumber(result[1]["y"]) local z = tonumber(result[1]["z"]) local int = tonumber(result[1]["interior"]) local dim = tonumber(result[1]["dimension"]) local rot = tonumber(result[1]["rotation"])
  6. Works perfectly fine. Thanks again Castillo! Edit: I have another little problem with the same script. I want to load all the ATMs if I restart the server, but it only loads the first one in the table. This is my code for that: local qh = dbQuery(connection, "SELECT * FROM atms") local result = dbPoll(qh, 500) local atmcount = 0 if (result) then if type(result) == "table" then for i, v in ipairs(result) do And then it basicly converts the result to numbers so that I can add the atms and hitmarkers. But as I said, it only creates the first one in the table. Does anyone know how to fix this?
  7. Hi there, I have a problem. I want to select all the rows of the mysql table, and then add 1 to that value. However, I don't know how to do this. I've tried around for an hour or so, just continiously trying different things, and I think this is the closest one I've come up with so far. (The connection works btw.) local atmidquery = dbQuery(connection, "SELECT COUNT(*) FROM atms") local atmidpoll = dbPoll(atmidquery, 500) if atmidpoll then atmid = tonumber(atmidpoll) + 1 else atmid = 0 end However, this doesn't work. It gives me the following error: attempt to perform arrithmic on nil value I am clueless on how to fix this, so maybe you guys can help me? Thanks in advance, Gtagasje.
  8. Well, I guess you helped me once again. It works perfect. Thanks Casti! (And Citizen!)
  9. No Citizen, that was not with your code. I tried your code, and it somehow works. Thanks for that. However, first time I tried with your code it gave me this error: [2013-10-27 17:13:50] WARNING: Vehicle\c.lua:133: Bad argument @ 'guiGridListSetItemText' [Expected string at argument 4, got nil] [2013-10-27 17:13:50] WARNING: Vehicle\c.lua:134: Bad argument @ 'guiGridListSetItemText' [Expected string at argument 4, got nil] So then I edited this: guiGridListSetItemText(veh_vehGrid, row, 1, tableRow[1], false, false) guiGridListSetItemText(veh_vehGrid, row, 2, tableRow[2], false, false) to this: guiGridListSetItemText(veh_vehGrid, row, 1, tostring(tableRow[1]), false, false) guiGridListSetItemText(veh_vehGrid, row, 2, tostring(tableRow[2]), false, false) and now it shows 'nil' on both columns, but it does add a row for each vehicle I own, so that works. Thank you for that. But do you have any idea how to fix this string problem?
  10. Alright, when I put outputChatBox in the server side it works, and in the client side too, but it doesn't work in the clientside when I put it after "for", so it's something with the table if I'm right.
  11. I had the vehicle, and recreated the table actually. It just didn't show up, but I'll add some outputChatbox around the script and see what works and what doesn't.
  12. Okay, thank you very much, but it doesn't work for some reason. I don't get any errors either. And about the data types, the tutorial I read said that it wasn't neccessary, so that's why I didn't have them in the table. Sorry for that. But I've copy-pasted your code and it still doesn't work. No debug errors either.
  13. I hope I understood you right, I changed the following things: Client: for i=1,#vehicles do to for i,vehTable in ipairs(vehTable) do Server: triggerClientEvent("openVehWindow", getRootElement(), vehicles, price) to triggerClientEvent("openVehWindow", thePlayer, vehicles, price) This does not add a row for each vehicle even though I have one, but it doesn't give an error either.
  14. Gtagasje

    SQL Amounts

    Hello there, I had a question about my script. Basicly, I want to execute a query to count the amount of vehicles a person has. Then I want to send that amount to the client side to create a row for each vehicle. I derped around with tables and what not, but I couldn't find a way myself, so that's why I am asking here. This is what I use to create the table: function createTables() executeSQLQuery("CREATE TABLE IF NOT EXISTS vehicles(vehicle,vehicleID,vehiclePrice,locked,x,y,z,hidden,account)") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createTables) I use this function on the server side: vehTable = { } function openVehWindow(thePlayer, cmd) local acc = getAccountName(getPlayerAccount(thePlayer)) local vehRes = executeSQLQuery("SELECT COUNT(vehicle) FROM vehicles WHERE account=?", acc) local priRes = executeSQLQuery("SELECT COUNT(vehiclePrice) FROM vehicles WHERE account=?", acc) if type(vehRes) == "table" and #vehRes > 0 and type(priRes) == "table" and #priRes > 0 then for i,v in pairs(vehRes) do vehicles = vehRes[1]["vehicle"] table.insert(vehTable, vehicle) end for i,v in pairs(priRes) do price = vehRes[1]["vehiclePrice"] table.insert(vehTable, price) end triggerClientEvent("openVehWindow", getRootElement(), vehicles, price) else outputChatBox("You don't have any vehicles!", thePlayer, 255, 0, 0) end end addCommandHandler("open", openVehWindow) And the client side: vehTable = { } function showVehWindow(vehicles, price) vehicleWindow() if (vehWdw ~= nil) then guiSetVisible(vehWdw, true) guiSetInputEnabled(true) showCursor(true) centerWindow(vehWdw) for i=1,#vehicles do row = guiGridListAddRow(veh_vehGrid) guiGridListSetItemText(veh_vehGrid, row, 1, vehicles[i], false, false) guiGridListSetItemText(veh_vehGrid, row, 2, price[i], false, false) end end end addEvent("openVehWindow", true) addEventHandler("openVehWindow", getRootElement(), showVehWindow) I get this error at the moment: ERROR: c.lua:132: attempt to get lenght of local 'vehicles' (a nil value) Please note that the code is quite messy at the moment, since I've been trying around for quite some hours. My apologies for that.
  15. Gtagasje

    Invincible

    Hello there, I have made a script that makes the players in the staff team invincible, atleast that's what I wanted to make, but whenever ANY player is in the staff team, all of the players in the other teams are also invincible. I don't know why, and I have tried a lot of things. This is my script: function StopDamage (theTeam) local players = getPlayersInTeam(getTeamFromName("Staff")) for i,v in pairs(players) do if getPlayerTeam(v) == getTeamFromName("Staff") then cancelEvent() end end end addEventHandler("onClientPlayerDamage", localPlayer, StopDamage) I think it should do what I want, but it turns out it doesn't. Thanks in advance, ~Gtagasje
  16. Really nice! I have seen it, and it looks awesome!
  17. Hi, I saw "export function" a while ago in a script, and I don't know what this is. So I got some questions about it. 1. What do exported functions do? 2. Are exported functions helpfull in scripts like police/clan systems? 3. How do you export a function? I hope these can be answered, because I really dont know what exported functions are. Thanks in advance. Gtagasje.
  18. If I don't want to do an event when someone hits a marker in a vehicle, I add this to my function: if getElementType(hitElement) == "player" and not isPedInVehicle(hitElement) then If this doesn't work, I don't know. Because Im not that good with scripting.
  19. Thanks both off you for helping me!
  20. Hi, I have made a vehicle gui already, and I know how to make it, but I always made it with buttons. Now, I need a lot of vehicles in a gui, so buttons is not an option anymore. So I made this gui with a gridlist, a column, and some rows, that shows up when you hit a marker. But now, I want it to spawn a vehicle, when you press the button spawn, and have a row selected. Ex: I have selected the row "Police Rancher" and click on spawn, and now I get a police rancher. But if I have not selected any row, it says in the chatbox "Please select a row first!". I dont have the code yet, cus I dont know a shit about gridlists. I hope any off you can help me with it. This is my whole code(client side): local VehMarker1 = createMarker( 1026.4000244141, -1451.4000244141, 13, 'cylinder', 1.0, 0, 0, 255, 255 ) local teams = {["SWAT"] = true, ["Staff"] = true} function createVehGui () MainGui = guiCreateWindow(308,125,400,485,"LWC SWAT Vehicle Panel",false) VehGrid = guiCreateGridList(70,55,261,287,false,MainGui) guiGridListSetSelectionMode(VehGrid,2) VehCol = guiGridListAddColumn(VehGrid,"SWAT Vehicles",0.2) Spawn = guiCreateButton(39,393,145,67,"Spawn",false,MainGui) guiSetFont(Spawn,"clear-normal") Cancel = guiCreateButton(219,393,145,67,"Cancel",false,MainGui) guiSetFont(Cancel,"clear-normal") PolLS = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, PolLS, VehCol, "Police LS", false, false ) PolLV = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, PolLV, VehCol, "Police LV", false, false ) PolSF = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, PolSF, VehCol, "Police SF", false, false ) PolRan = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, PolRan, VehCol, "Police Rancher", false, false ) PolEnf = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, PolEnf, VehCol, "Police Enforcer", false, false ) SWATTruck = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, SWATTruck, VehCol, "SWAT Truck", false, false ) end addEventHandler("onClientMarkerHit", vehMarker, function ( hitElement ) if hitElement == localPlayer and getPlayerTeam ( hitElement ) and teams[getTeamName(getPlayerTeam ( hitElement ))] then createVehGui ( hitElement ) if (MainGui ~= nil) then guiSetVisible(MainGui, true) showCursor(true) guiSetInputEnabled(true) else outputChatBox ("Error: Please Re-enter the marker to get your vehicle keys.", getRootElement(), 255, 0, 0) end end end ) Thanks in advance. Gtagasje.
  21. Ok, i'll try that. Edit: It works! Thank you very much!
  22. I made this in like 1 minute, but it might be full off fault's. function setmode () setDevelopmentMode(true) end addEventHandler("onClientPlayerJoin", getRootElement(), setmode) It is client. And I have this in my meta: client="1.1.1-9.03355" server=""/>
  23. Hi, I was trying to make a gate move with a colshape, since I did it always with markers. I wanted to see where my colshape was, because it was not at the place where the gate is. So I tried this command which I found in another post about this: "/crun setDevelopmentMode(true)" but I didn't get any message, and when I type after that command this ingame: "/showcol" or "/showcol 1" I get this in my console: "showcol set to 1, but this will not have any effect because development mode is off." And yes, I have read the wiki already, so just coppieing from the wiki won't help me. Thanks in advance. Gtagasje.
×
×
  • Create New...