Jump to content

WorthlessCynomys

Members
  • Posts

    369
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by WorthlessCynomys

  1. I'll just repost your code in code mode real quick. Next time, use code, so it is actually readable. addEventHandler("onResourceStart",getResourceRootElement(getThisResource)) call ( getResourceFromName ( "scoreboard" ), "scoreboardAddColumn", "Online" ) addEventHandler ( "onResourceStart" , resourceRoot , function ( ) for index , player in ipairs ( getElementsByType ( "player" ) ) do local pAccount = getPlayerAccount ( player ) if not isGuestAccount ( pAccount ) then local minutes = getAccountData ( pAccount , "Online.minutes" ) if minutes then local hours = getAccountData ( pAccount , "Online.hours" ) if # tostring ( minutes ) == 1 then minutes = "0" .. minutes end if # tostring ( hours ) == 1 then hours = "0" .. hours end setElementData ( player , "Online" , hours .. " H " .. minutes .. " M" ) local timer = setTimer ( updatePlayerOnline , 60000 , 1 , player ) setElementData ( player , "Online.timer" , timer ) else setAccountData ( pAccount , "Online.minutes" , 0 ) setAccountData ( pAccount , "Online.hours" , 0 ) setElementData ( player , "Online" , "00 H 00 M" ) local timer = setTimer ( updatePlayerOnline , 60000 , 1 , player ) setElementData ( player , "Online.timer" , timer ) end else setElementData ( player , "Online" , "N/A" ) end end end ) addEventHandler ( "onResourceStop" , resourceRoot , function ( ) for index , player in ipairs ( getElementsByType ( "player" ) ) do local pAccount = getPlayerAccount ( player ) if not isGuestAccount ( pAccount ) then local timer = getElementData ( player , "Online.timer" ) if isTimer ( timer ) then killTimer ( timer ) end end end end ) addEventHandler ( "onPlayerLogin" , root , function ( _ , pAccount ) local minutes = getAccountData ( pAccount , "Online.minutes" ) if minutes then local hours = getAccountData ( pAccount , "Online.hours" ) if # tostring ( minutes ) == 1 then minutes = "0" .. minutes end if # tostring ( hours ) == 1 then hours = "0" .. hours end setElementData ( source , "Online" , hours .. " H " .. minutes .. " M" ) local timer = setTimer ( updatePlayerOnline , 60000 , 1 , source ) setElementData ( source , "Online.timer" , timer ) else setAccountData ( pAccount , "Online.minutes" , 0 ) setAccountData ( pAccount , "Online.hours" , 0 ) setElementData ( source , "Online" , "00 H 00 M" ) local timer = setTimer ( updatePlayerOnline , 60000 , 1 , source ) setElementData ( source , "Online.timer" , timer ) end end ) addEventHandler ( "onPlayerLogout" , root , function ( pAccount ) local timer = getElementData ( source , "Online.timer" ) if isTimer ( timer ) then killTimer ( timer ) end end ) addEventHandler ( "onPlayerJoin" , root , function ( ) setElementData ( source , "Online" , "N/A" ) end ) addEventHandler ( "onPlayerQuit" , root , function ( ) local pAccount = getPlayerAccount ( source ) if not isGuestAccount ( pAccount ) then local timer = getElementData ( source , "Online.timer" ) if isTimer ( timer ) then killTimer ( timer ) end end end ) function updatePlayerOnline ( player ) local pAccount = getPlayerAccount ( player ) local minutes = getAccountData ( pAccount , "Online.minutes" ) local hours = getAccountData ( pAccount , "Online.hours" ) minutes = tostring ( tonumber ( minutes ) + 1 ) if minutes == "60" then hours = tostring ( tonumber ( hours ) + 1 ) minutes = "00" end setAccountData ( pAccount , "Online.minutes" , tonumber ( minutes ) ) setAccountData ( pAccount , "Online.hours" , tonumber ( hours ) ) if # tostring ( minutes ) == 1 then minutes = "0" .. minutes end if # tostring ( hours ) == 1 then hours = "0" .. hours end setElementData ( player , "Online" , hours .. " H " .. minutes .. " M" ) local timer = setTimer ( updatePlayerOnline , 60000 , 1 , player ) setElementData ( player , "Online.timer" , timer ) end
  2. effect createEffect ( string name, float x, float y, float z [, float rX, float rY, float rZ, float drawDistance = 0 ] ) function Jets() local x, y, z = getElementPosition(localPlayer) for i=0, 20 do createEffect ("petrolcan", x + math.random(-5,5), y + math.random(-5,5), z) end end addCommandHandler("jet", Jets) -- There were multiple problems. First of all, local isn't a function. You don't have to close it. local just makes variables exist only in the code block it is in. In other words, varibales starting with local like "local pig = 'animal'" only exist until you end the function it is in. -- createEffect's first argument have to be string. -- You had a "(" before x, but you did not close it.
  3. ----------------- -- CLIENT SIDE -- ----------------- function createHydrants() local x, y, z = getElementPosition(localPlayer) -- Get your location. for i=0, 20 do -- 20 Hydrants. fxAddWaterHydrant(x + math.random(-5,5), y + math.random(-5,5), z) -- Using math.random, and your current location 20 water hydrants are created. end end addCommandHandler("hyd", createHydrants) Here it is. The working code. The problem was the "local" in the functions arguments. local is a reserved word for lua. You can't use it as variable, and you don't have to define it.
  4. It says that fxAddWaterHydrant is not an existing command. Now. fx functions are client side. I assume your tried to do that on server side.
  5. You use colshape to open it and marker to close it. The problem is with the events. Btw use code sign next time.
  6. You can also detect if the vehicle is in a rolling state and apply a little rotation to it with setVehicleTurnVelocity. Or you can do that based on speed, so if you spin at 200, you'll do plenty of barell rolls.
  7. I'd play with the vehicle handlings to reach that effect. Just in case you haven't thought about that. But I'm not into vehicle scripts, so that's just a guess.
  8. Oh... nevermind. Sorry, I just saw that you posted the vehicle realism system. I'm a bit tired. Sorry again.
  9. Well... that's something, I've never done. --But maybe table1 = {1,3,9,2} table2 = {3, 10, 4, 6} tableCount = #table1 for i, v in ipairs(table2) do table1[tableCount+i] = v end
  10. Allright. I don't wanna confuse you, but if you want to store a color i.e in a table but in one "slot", You can have tables within tables. myTable = {1, 8, {255, 0, 0, 255}, 3} -- And you handle it like: myTable[3][1] -- This is 255
  11. Out of pure curiosity, did that code work? Cuz i've never declared 3 values to one table "slot" like that (Table[3]). Btw, team effort... that's what community's for.
  12. -- You declare the table myTable = {} -- Have an element (I'll make one here) myTable[1] = createPed(29, 0, 0, 0) -- OR ped = createPed(29, 0, 0, 0) myTable[1] = ped -- OR ped = createPed(29, 0, 0, 0) table.insert(myTable, ped) -- This will insert the ped in the table as an adittional element, unless you declare an index, while the upper ones overwrite myTable[1]
  13. So in Lua {} this is a table. Tables have indexes and values So like: exampleTable = {1, 8, 4} --[[ The index is the place in this table. So like the Index of 1 is 1, cuz it's on the first place of the table, it's value is 1. The index of 8 is 2, the value is 8..... you can get an exact value from the table by exampleTable[2] for example. exampleTable[2] is 8. --]] exampleTable2 = {"toy", "story"} --[[ The index of "toy" is 1, the value is "toy". You get "toy" as result by exampleTable2[1] --]] exampleTable3 = {toy = 1, story = 8} --[[ The index of 1 is "toy", it's value is 1. Same with story. You get 8 as result by exampleTable3["story"] --]] --[[ You can also handle tables with for loops. If your table has only numerical INDEXES, your loop will look like this: --]] for i, v in ipairs(exampleTable2) do outputChatBox(v) --This will output all outputable values of that table. end -- If your table has indexes, not numbers u use "pairs" for i, v in pairs(exampleTable3) do outputChatBox(v) end If you need further help, I'll do my best to help you.
  14. Hy. As I know, it is not possible, unless you make some tricky solution with some variables or such. I never tried tbh, it doesn't worth the time for me.
  15. @50cent you should read the function carefully... the last 3 arguments of that function is face toward xyz, which makes your material's facing fix, and NOT relative to the player.
  16. Csak 2 eve lett postolva Mindenki csak beleköt valamibe
  17. Yes, it basically the same as relative GUI, that's true, but relative GUI isn't that precise. I know it from experience. On the other hand, thank you for telling me about the mistakes, i edited it.
  18. Hello. You have to use the SQL functions, which are: dbConnect() dbQuery() dbPoll() dbExec() If you need further explanation about how to use SQL, send me a message and I'll try to explain it. You also have to check the access of the player, which is a simple if-then. So like, I have a value from SQL that he is a police member. The variable of this value is for example: group. So if the player does something that requires the police group you do it that way: if (group == "police") then -- Do something end Same here, if you need further explanation, I'll be glad to help you. Other way is to store players in ACL groups, but that is not SQL based.
  19. Hello. Now... guis have a Relative argument, but that's :~ty, so DO NOT use it. Instead, you can do it like: local sx, sy = guiGetScreenSize() guiCreateWindow(sx*0.5, sy*0.5, sx*0.2, sy*0.2, "Window", false) This makes your gui's TOP LEFT CORNER be at the screen's 50% at width and height too, and your gui's size will be 20% of the screen at width and height as well. IMPORTANT: if you use this technique, make sure that the relative argument is set to FALSE.
  20. Hello! If I wanted to do this, I'd use: setTimer setElementPosition onPlayerDamage killTimer addEventHandler and addCommandHandler I hope it helps!
  21. Hello! Since dxText have to be drawn at every frame (onClientRender), the easiest way to move the text is to redefine it's position at every frame or with some method you prefer.
×
×
  • Create New...