Jump to content

Blinker.

Members
  • Posts

    148
  • Joined

  • Last visited

Everything posted by Blinker.

  1. Hello , these are the functions and events you need : onClientGUIClick triggerServerEvent killPed setElementFrozen guiSetVisible this is a simple example: --client side window = guiCreateWindow ( 0.3, 0.3, 0.5, 0.4, "window", true ) closebutton = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "close", true,window ) freezebutton = guiCreateButton( 0.2, 0.1, 0.2, 0.1, "freeze", true,window ) killbutton = guiCreateButton( 0.2, 0.5, 0.2, 0.1, "kill", true,window ) addEventHandler("onClientGUIClick",root, function () if source == closebutton then guiSetVisible(window,false) elseif source == freezebutton then setElementFrozen ( localPlayer, true ) elseif source == killbutton then triggerServerEvent("killplayer",localPlayer,localPlayer) end end) --server side function killplayer(thePlayer) killPed(thePlayer,thePlayer) end addEvent("killplayer",true) addEventHandler("killplayer",root,killplayer)
  2. in race it doesn't work , race integrity will fail.
  3. Hello , i came back to that problem , hopefully i'll find a solution for that problem... i forgot about this topic and that problem because i stopped working on this script. if anyone could help me i'll be so grateful, Thanks. Btw , destoryElement Doesn't work.
  4. It works Thanks a lot both of you
  5. well and how will it save the data ? i tried that : addCommandHandler("ins", function (_,_,name) t = {} table.insert(t,name) str = toJSON ( t ) end) function output() local t2 = fromJSON ( str ) -- Now we convert it back to table for _, v in pairs ( t2 ) do outputChatBox (v ) -- output the values end end addCommandHandler("out",output) when i do /ins Blinker , and then /out , it shows Blinker in chat box , but when i restart the resource and do out , i get nothing. Thanks. EDIT: i think i misunderstood , is this function used to save the data or ?
  6. @Saml1er i dont know anything about db , JSON ... i tried even to use them, but i found it's so hard to understand + errors @Gallardo nono the question was for another script. i wanted to save a table with nicknames of players.
  7. okay mate , thanks a lot
  8. addEventHandler("onPlayerWasted",root, function() if (#getAlivePlayers == 1) then outputChatBox(getPlayerName(source).." 2nd") end end)
  9. thank you both also i have a question is there a way to save a table's data after restarting the resource ? without using toJSON and SQL .. these things.
  10. Hello , what's the easier and best way to get alive players in a team well i'm using onRaceStateChanging to increase the number of players and onPlayerWasted to decrease the number of players but i get many bugs ... when the player changes his nick and many others. Thanks in advance.
  11. viewtopic.php?f=91&t=82700&p=754037#p754037
  12. Fixed , Many Thanks to LinKin helped me at Skype and Thank you all.
  13. I tried that , it saves everything .. even if the names are the same.
  14. And what's that for ? if i use this it won't delete the repeated names like 'Blinker changed to Blinker1' and then 'Blinker1 changed to Blinker' i want it to save 'Blinker Blinker1' instead of 'Blinker Blinker1 Blinker1 Blinker'
  15. Hello , i've tried what LinKin said to stop repeating the same names .. this is what i tried: local Names = {} function onPlayerChangeNick(o,n) local pSerial = getPlayerSerial(source) if not Names[pSerial] then Names[pSerial] = {} table.insert(Names[pSerial], {o, n}) else for i , nick in ipairs (Names[pSerial]) do if (not nick == o) or (not (nick == n)) then table.insert(Names[pSerial], {o, n}) end end end for i , v in ipairs (Names[pSerial]) do outputChatBox(i..": Old: "..v[1].." -> New: "..v[2], source) end end addEventHandler('onPlayerChangeNick',root,onPlayerChangeNick) --ERROR : aborting; infinite running script 'script name' Thanks.
  16. I don't mean changing to the same nick , i mean like if the player had "Blinker" name and then he changed to "Sasu" , then he changed back to "Blinker", in the table i will have Blinker,Sasu,Sasu,Blinker .. how to prevent that ? Thanks
  17. Thanks a lot , last question how to check if the table has the same name ?, like "Blinker" and "Blinker" remove 1 of them i dont want to insert 2 same nicks
  18. Yes it does well what i'm trying to do is to save the player's nicks .. that's what i'm trying to do : function onPlayerChangeNick(o,n) if not Names then Names = {} Names[getPlayerSerial(source)] = o , n else Names[getPlayerSerial(source)] = Names[getPlayerSerial(source)] , o ,n end for i , v in ipairs (Names) do outputChatBox(Names[getPlayerSerial(source)]) end end addEventHandler('onPlayerChangeNick',root,onPlayerChangeNick)
  19. Of Course i did , it was just an example.
  20. it's working thanks, i have another question when i use example[player][1] = Smth if gives me the same error so i wonder what's the problem , btw it's another script not the same one .. just giving an example Thanks again
  21. Hello , this is a piece of my code where the problem occurs if (#getAlivePlayers() == 1) then for i ,v in ipairs (getAlivePlayers()) do score[v] = score[v] + 4 end end so when a player wins the round , i get: Error: attempt to perform arithmetic on field '?' (a nil value) Thanks.
  22. Aa no , you misunderstood me, I didn't mean that the car becomes on fire on 25% and then goes down till 0 I meant I want it normal like 90 to 87 not going from 25 to 0 ,so whenever the car reaches 0 % of health it becomes on fire. Normaly the car becomes on fire at 25%... Thanks.
  23. function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function addPlayer (thePlayer,cmd,target) local target = getPlayerFromPartialName(target) if target then setPlayerTeam(target,getPlayerTeam(thePlayer)) end end addCommandHandler("addplayer",addPlayer)
×
×
  • Create New...