Jump to content

Crosshair

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by Crosshair

  1. Hello all. Lets say some players have set an elementdata called "x" with the value "y". I need a function that gets all those players that have getElementdata(player, "x") == "y" and sends a outputChatBox to all of them. PS: I did something but i can`t test it right now since i`m the only player on the server local players = getElementsByType( "player" ) for i=1,#players do if (getElementData(players[i], "x") == "true") then outputChatBox("test", players[i]) end end Could this work ?
  2. i figured this, but i dont` have an idea how to make this work. Any idea ?
  3. I`m trying to make a progress bar with dxdraw. All works well but the rectangle flickers every time till the timer stops. I need help on that so the rectangle would not flicker anymore. local screenW, screenH = guiGetScreenSize() function render() if (isTimer(timer) == false) then i=0 timer = setTimer(function() dxDrawRectangle((screenW - 23) / 2-131, (screenH - 10) / 2, i, 10, tocolor(144, 3, 3, 255), true) i=i+1 end, 50, 100) end removeEventHandler("onClientRender", root, render) end addEventHandler("onClientRender", root, render)
  4. Well thank you for the support and i`l see tomorrow what i will do.
  5. There is also no "plantID" variable declared. I just didn`t included the variable. I make another thing right now. I added on the top id = 0, removed the id argument and add id=id+1 before it creates the object. Now if i use table.insert how do i retrieve the emelents ? with unpack ? What is the best option to do this ? Mine or yours ?
  6. Your right, but i want the player to not enter a number. Just to type plant and the plant will later rise from the ground, So i need the script to add the plant1 in the table with the first position and if he decides to add another plant(plant2) to be added also in the table with the second position. If i don`t use the cmd argument this works and if i use outputchatbox(plants[1]) works.
  7. Hi. I`m trying to make 2 commands that uses one command and i have some problems. plants = { } function plants(thePlayer, cmd, id) if (cmd == "plant") then local x,y,z = getElementPosition(thePlayer) plants[id] = createObject(plantID,x,y,z) end if (cmd == "harvest") then --TODO end end addCommandHandler("plant", plants) addCommandHandler("harvest", plants) When i enter the command "plant" gives me an error at plants[id] = createObject(plantID,x,y,z): table index is nill. If i remove the argument "cmd" from the function all works well.
  8. Hello guys. I tried to make a job and i run in some issues. function enter(thePlayer) marker = createMarker(2809, -2474, 13, "cylinder", 2, 248, 211, 6, 153, thePlayer) blip = createBlip(2809, -2474, 13, 0) addEventHandler("onMarkerHit", marker, marcar) end addEventHandler ( "onVehicleEnter", getRootElement(), enter ) function marcar(thePlayer) destroyElement(marker) destroyElement(blip) end I simplify the code to this. The problem is with destroyElement of course. Bad 'element' pointer @ 'destroyElement'(1) marker and blip is gone but i want to get rid of this warning.
  9. But it`s not. If i put outputDebugString(jucatori) in server side returns the values.
  10. Expected string, got nil at "jucatori"
  11. How about this ? function sql(thePlayer) team = getPlayerTeam(thePlayer) teamstr = getTeamName(team) local sql = mysql:query("SELECT `username` FROM `accounts` WHERE `factiune` = '"..teamstr.."'") if (sql) then while true do row = mysql:fetch_assoc(sql) if (not row) then break end jucatori = row["username"] triggerClientEvent(source, "factiunemeniu", getRootElement(), jucatori) end mysql:free_result(sql) end end addEventHandler("onPlayerJoin", getRootElement(), sql) function factiunemeniu(jucatori) meniu = guiCreateWindow(233,164,600,440,"Meniu factiune",false) grid = guiCreateGridList(9,29,467,379,false,meniu) local nume = guiGridListAddColumn(grid,"Nume",0.2) outputDebugString(jucatori) for k, v in ipairs (jucatori) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, nume, jucatori, false, false) end end addEvent("factiunemeniu", true) addEventHandler("factiunemeniu", getRootElement(), factiunemeniu) On outputDebugString(jucatori) returns nil. In server side the debug shows
  12. To be more precise: http://i.imgur.com/j5Pc1.png Add those in a gridlist
  13. Still nothing. Got only one result.
  14. No warning but shows only one result.
  15. Yes. Should i use fetch_assoc ?
  16. bad argument at ipairs. Table expected, got number
  17. Can you help me fix it then ? The script should get my team name, search for the players that has the same team and put them in a gridlist
  18. You mean change setElementData(source, "jucatori", jucatori) to setElementData(source, "jucatori", row) ? This will give me a warning that guiGridListSetItemText expects string and not a table.
  19. Hello. I want to fetch some data from sql and add in the gui but is not working. addEvent("nume", true) addEventHandler("nume", getRootElement(), function(team) local teamstr = getTeamName(team) local sql = mysql:query("SELECT `username` FROM `accounts` WHERE `factiune` = '"..teamstr.."'") if (sql) then while true do local row = mysql:fetch_assoc(sql) if (not row) then break end local jucatori = row["username"] setElementData(source, "jucatori", jucatori) end mysql:free_result(sql) end end) if i debug row["username"] it returns all those users that has my team. grid = guiCreateGridList(9,29,467,379,false,meniu) local nume = guiGridListAddColumn(grid,"Nume",0.2) local team = getPlayerTeam(getLocalPlayer()) if (team) then local players = getPlayersInTeam(team) for k, v in ipairs(players) do triggerServerEvent("nume", getLocalPlayer(), team) local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, nume, getElementData( localPlayer, "jucatori"), false, false) end end in grid only shows one user.
  20. Crosshair

    Unique ID

    Hello. I have a question about vehicle id`s. I want to add all the vehicles in sql(add and delete in game). Adding is easy, but let`s say i want to delete a vehicle. How do i do that ? Using set/getElementData should do it, but there will be dozens of vehicles in the database. Anyone has some idea ?
  21. Hi guys, i have an issue with a marker. Guess could help me with it. I enter marker1, i get the job and marker2 appears. When i enter marker2 something happens. The problem is with marker2. It does nothing. function on_btn_join_clicked(button, state) if (button ~= "left") or (state ~= "up") then return end triggerServerEvent("jf", getLocalPlayer()) local marker2= createMarker (-1208.7, -1073.8, 127.2, "cylinder", 1.5, 248, 211, 6, 153 ) setElementData(localPlayer, "jobm", marker2) showCursor(false) guiSetVisible(fwdw, false) end [.......................] function jstart(element) if getElementType(element) == "player" and (element == localPlayer) then outputChatBox("test") end end addEventHandler("onClientMarkerHit", getElementData( localPlayer, "jobm"), jstart) addEvent("jf", true) addEventHandler("jf", getRootElement(), function() mysql_query(handler, "UPDATE `lm`.`accounts` SET `jobsecundar` = '1' WHERE `accounts`.`username` = '"..getPlayerName(source).."';") outputChatBox("test") end)
  22. Is there a function that does that or how do i do it?
×
×
  • Create New...