Jump to content

FWCentral

Members
  • Posts

    161
  • Joined

  • Last visited

Everything posted by FWCentral

  1. the buy works the first time so say i type /sell then anyone can buy from me, But then if i stop selling sell again no one can buy.
  2. Selling: thearmsmark = {} function sell(source, commaneName) setElementFrozen(source, true) local x,y,z = getElementPosition(source) thearmsmark[source] = createMarker( x, y, z, "cylinder", 1.2, 255, 0, 0, 170 ) setElementData(source,"SellingArms", true) setElementData(thearmsmark[source], "ownedby", getPlayerName(source)) end Buying: function buy(source) local x,y,z = getElementPosition(source) local colshape1 = createColSphere(x-3,y+3,z-4,10) local players = getElementsWithinColShape ( colshape1, "player" ) for i,seller in ipairs(players) do if getElementData(seller, "SellingArms") == true then if isElementWithinMarker(source, thearmsmark[seller]) then setElementData(source,"BuyingArmsFrom", getPlayerName(seller)) triggerClientEvent("showarmspanelARMS", source) destroyElement(colshape1) else end end end end changed it to the element too thanks
  3. Back to this again I got a problem, When i create the marker i made it like this trying to put it in a table: thearmsmark = {} thearmsmark[getPlayerName(source)] = createMarker( x, y, z, "cylinder", 1.2, 255, 0, 0, 170 ) it creates the first marker and lets the player sell fine, but then when you try to do it a second time it wont let you, It will create the marker but you cant buy from the player and im not sure whats up with it because there is no errors
  4. How can i check if a field in the database already exists? Here's what i tried: local gname2 = executeSQLQuery("SELECT groupName FROM Groups_members WHERE name = ?",getAccountName(getPlayerAccount(player))) or nil if gname2 ~= nil then But i get an error: attempt to index field ? a nil value
  5. Ok ill explain more mate, there is a gridlist in the GUI that i created and it is to show all the members in the group. I need to send the data "name" and "rank" from the server to the client. local member = executeSQLQuery("SELECT name FROM Groups_members WHERE groupName = ?",tostring(name))-- This is to get the member ( tostring(name) is the name of the groupName in Groups_members ) local prank = executeSQLQuery("SELECT rank FROM Groups_members WHERE name = ?",tostring(member)) -- then get the rank of that player local member = executeSQLQuery("SELECT name,rank FROM Groups_members WHERE name = ?",tostring(name))-- ok now im confused i dont know why ive done this. Anyway i want to trigger to the client with the each players rank and name like: triggerClientEvent("addName", source,name,rank) Edit Nevermind guys it works now i just needed to do this: local member = executeSQLQuery("SELECT name,rank FROM Groups_members WHERE groupName = ?",tostring(name)) for i, plname in ipairs(member) do triggerClientEvent("addName", source,plname.name,plname.rank) Thanks guys
  6. Thanks man i got another problem, I want to send the name and the rank from Group_members but how can i loop 2 things at once? I tried this: local member = executeSQLQuery("SELECT name FROM Groups_members WHERE groupName = ?",tostring(name)) local prank = executeSQLQuery("SELECT rank FROM Groups_members WHERE name = ?",tostring(member)) local member = executeSQLQuery("SELECT name,rank FROM Groups_members WHERE name = ?",tostring(name)) for i, plname in ipairs(member,prank) do triggerClientEvent("addName", source,plname.name,plname.rank) I didn't get any error but it didn't work
  7. Yeah that worked Solidsnake thanks, I don't know what the problem was
  8. I get an error when i tried that: database query failed near "group": syntax error
  9. Hey im trying to create a SQLite table; function ontStart (r) if r == getThisResource() then executeSQLCreateTable ( "Groups", "name TEXT, type TEXT, level NUMBER") -- creates this fine. executeSQLCreateTable ( "Groups_members", "name TEXT, group TEXT, rank TEXT") else end end addEventHandler ( "onResourceStart", getRootElement(), ontStart ) It shows the table Groups in the SQLite browser but not Groups_members, Although in the console it says it has been created, Will it still be there? Edit: No it isn't there what is the problem? it creates the other fine even when i remove Groups from the script and just try create the other it doesn't
  10. Ok thanks Solidsnake and Stanley
  11. It works thank you! but how does this work? local gangName = gang [ 1 ] [ "gang" ]
  12. I didn't want to start a new topic but i got another problem, Im trying to spawn a player; function spawn(source, spawn) outputChatBox("work1") local gang = executeSQLQuery("SELECT gang FROM Spawn WHERE name = ?",tostring(spawn)) if gang == "none" then outputChatBox("work2") elseif gang ~= "none" then outputChatBox("work3") end end It shows in the chatbox work1 and work3 but the gang in the db is "none" (without quotes)
  13. The numbers are coming from a db, so like this? local skins = ( skin1, skin2, skin3 ) skins [ math.random ( #skins ) ]
  14. Doesn't that only work say if i put math.random(1,20) it will pick a random number between them? and i should have said the 3 numbers are non consecutive.
  15. Ok i have 3 numbers, How can i pick a random number out of them?
  16. It works perfect like this; function updateLocations ( location ) for i=0, guiGridListGetRowCount(locationsList)do if isTextInGridList(locationsList, 1, location) == false then guiGridListSetItemText ( locationsList, guiGridListAddRow ( locationsList ), 1, location, false, false ) end end end With the function he added above, Thanks Jaysds1 and karthik184 awesome guys
  17. Haha i can't see why it wouldn't its pretty annoying though and ok thanks man function updateLocations ( location ) for i=0, guiGridListGetRowCount(locationsList)do -- loop through the gridlist if(location~=guiGridListGetItemText(locationsList,i,1))then --if the location name is not inside the gridlist then guiGridListSetItemText ( locationsList, guiGridListAddRow ( locationsList ), 1, location, false, false ) -- add a row and set it by the location name outputChatBox("Type: "..type(location).." added : "..location) elseif(location==guiGridListGetItemText(locationsList,i,1))then outputChatBox("Type: "..type(location).." removed : "..location) end end end Using it like this outputs like; Type: string added : LS Type: string added : Cheese Type: string removed : Cheese Type: string removed : LS Type: string added : LS Type: string removed : LS Type: string added : dwd Type: string added : dwd Type: string added : dwd Type: string removed : dwd
  18. Now it shows it like this; LS cheese LS dwd dwd dwd But there is only one dwd in the DB and 2 LS and one Cheese
  19. No it sends it one by one from a table mate
  20. But how hard is it to see if there is already a row with the same name? I wouldn't think it will be the code looks fine i just can't get my head around it
  21. When the GUI is created it triggers a server event that returns the locations to that function, The server side all works fine. Then the gui will be destroyed later when its closed, Only reason for this is because i want to keep the GUI up to date each time a player spawns if there is a new location added to the GUI it will show or is there an easier way to do that?
  22. Now it only shows one row and none of the others i did already try that mate
×
×
  • Create New...