Jump to content

WhoAmI

Members
  • Posts

    1,248
  • Joined

  • Last visited

Everything posted by WhoAmI

  1. function onDeath() triggerClientEvent(source, "openGUI", source) takeAllWeapons ( source ) setElementHealth ( source, 100 ) end addEventHandler("onPlayerWasted", getRootElement(), onDeath)
  2. So as far as I can see, you have seen low amount of things. If he doesn't want to rubish the internal.db database he is creating new one with name that he wants to set. That's normal. And yes, you are spamming. Stop.
  3. Move setElementHealth to s-side.
  4. If you don't know what are you talking about just stop posting. He can create his own SQLite database in his own .db file in his own resource if he wants to. Now I am asking you. Are you serious? Nevermind, stop spamming.
  5. Because if he wants to have db file in resource he has to create the file and add it to meta. That's obvious.
  6. -- CHANGE IF NECCESSARY dataName = { ["last"] = "Last Drift", ["total"] = "Total Drift", ["best"] = "Best Drift" } -- type here what the elementData's names addEventHandler ( "onResourceStart", root, function ( ) -- creating connection and if true creates column if not exist connection = dbConnect ( "sqlite" , "Drift_DB.db" ) if ( connection ) then dbQuery ( connection , "CREATE TABLE IF NOT EXISTS `drift` ( `data` TEXT, `account` TEXT )" ); end -- creating connection and if true creates column if not exist end ); function saveDriftPoints ( ) local account = getPlayerAccount ( source ); -- getting account if ( isGuestAccount ( account ) ) then -- checking if it is valid account return; end local accName = getAccountName ( account ); -- getting name local t = { } -- creating table for drift's data for k, v in pairs ( dataName ) do local data = getElementData ( source, v ); if ( data ) then t[v] = data; -- inserting values to table from ElementData end end local check = dbPoll ( dbQuery ( connection, "SELECT `data` FROM `drift` WHERE `account`=?", accName ), -1 ); -- checking if exist row if ( #check > 0 ) then dbExec ( "UPDATE `drift` SET `data`=? WHERE `account`=?", toJSON ( t ), accName ); -- if yes updating elseif ( #check == 0 ) then dbExec ( "INSERT INTO `drift` ( `data`, `account` ) VALUES ( ?, ? )", toJSON ( t ), accName ); -- if not creating end end addEventHandler ( "onPlayerQuit", root, saveDriftPoints ); function loadDriftPoints ( _, account ) if ( isGuestAccount ( account ) ) then -- checking if it is valid account return; end local accName = getAccountName ( account ); -- getting name local check = dbPoll ( dbQuery ( connection, "SELECT `data` FROM `drift` WHERE `account`=?", accName ), -1 ); -- checking if row exist if ( #check > 0 ) then -- if yes local d = check[1]; local t = fromJSON ( d["data"] ); if ( type ( t ) == "table" ) then for k, v in pairs ( t ) do setElementData ( source, k, v ); -- setting ElementData from saved drift's table in table end end end end addEventHandler ( "onPlayerLogin", root, loadDriftPoints ); This is s-side script. Didn't test. Change values in table on top and check. Create 'Drift_DB.db' file and add also to meta.xml line <file src="Drift_DB.db" />
  7. WhoAmI

    Help GUI!

    Use spawnPlayer instead.
  8. WhoAmI

    Burning punch

    I would replace onPlayerDamage with onPlayerContact, because he wants to set player on fire when he hits the ped with specific scin if I'm right.
  9. addEvent("sendMessageAgain", true) myMessages = { "Message 1", "Message 2", "Message 3" } addEvent("sendMessageAgain", true) function sendMessageBack() for i=1,3 do triggerClientEvent(source, "sendMessage", source, myMessages[i]) end outputChatBox("Resource started") end addEventHandler("sendMessageAgain", resourceRoot, sendMessageBack) addEvent("sendMessage", true) function myMessage(message) outputChatBox(message) end addEventHandler("sendMessage",resourceRoot,myMessage) function startIt() triggerServerEvent("sendMessageAgain", localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, startIt)
  10. viewtopic.php?f=91&t=87245 User had similar problem. The solution is onClientResourceStart event.
  11. onResourceStart event is called before loading client-side script. You are triggering an event which isn't loaded yet.
  12. By using dbConnect you are able to connect to SQLite and MySQL database. SQL dbConnect( "sqlite", "file.db" ) MySQL host = "localhost"; name = "database_name"; user = "user"; password = "password"; dbConnect( "mysql", "dbname=" .. name .. ";host=" .. host, user, password, "share=1" )
  13. So you want to do that if player enters the marker and he will wait there 2 seconds he will get money or what?
  14. local easing = "OutBounce" local time = 2000 local open = false function openGarageGate(thePlayer, cmd, garageID) if not garageID then outputChatBox("SYNTAXA: /"..cmd.." [iD Garage]", thePlayer, 255, 255, 0) else local garageID = tonumber(garageID) for i, v in ipairs (getElementsByType("object")) do if (getElementModel(v) == 17950) then local gate = getElementData(v, "poarta") local dbid = tonumber(getElementData(v, "dbid")) if (dbid == garageID) then local gateX, gateY, gateZ = getElementPosition(v) --moveObject(v, time, gateX+4.9, gateY+9.6, gateZ, 0, 0, 0, easing) moveObject(v, 17951, 1588.5490234375, -1637.95546875, 16.446516990662, -90, 0, 0) outputChatBox("You have opened your garage!", thePlayer, 0, 255, 0) open = true return; else outputChatBox("You are too far away from the garage!", thePlayer, 255, 0, 0) end end end end end addCommandHandler("opengarage", openGarageGate) Try this. Also doing like that open = true You are setting value of this variable to everyone in the server while you are using it s-side.
  15. progressBars = { }; function dxCreateProgressBar ( x, y, width, height, n ) local id = #progressBars + 1; progressBars[id] = { }; progressBars[id]["x"] = x; -- x position progressBars[id]["y"] = y; -- y position progressBars[id]["w"] = width; -- width progressBars[id]["h"] = height; -- height progressBars[id]["n"] = n; -- number of bars progressBars[id]["p"] = 0; -- progress local element = createElement ( "dxProgressBar", tostring ( id ) ); return element; end function dxProgressBarSetProgress ( element, progress ) if ( progress >= 0 and progress <= 1 ) then if ( isElement ( element ) ) then progressBars [ tonumber ( getElementID ( element ) ) ]["p"] = progress; return true; end end return false; end function drawProgressBars ( ) for _, p in pairs ( getElementsByType ( "dxProgressBar" ) ) do local id = tonumber ( getElementID ( p ) ); if ( id ) then local x, y, w, h, n, p = progressBars[id]["x"], progressBars[id]["y"], progressBars[id]["w"], progressBars[id]["h"], progressBars[id]["n"], progressBars[id]["p"]; local widthOfOne = ( w / n ) - 5; local widthOfOneWithBreaks = widthOfOne + 5; for i=0,n do dxDrawRectangle ( x + ( i * widthOfOneWithBreaks ), y, widthOfOne, h, tocolor ( 0, 0, 0, 255 ) ); end local np = math.floor ( ( n * p ) + 0.5 ); local wp = ( ( w + ( n * 5 ) ) * p ) / n for i=0,np do if ( i == np and p ~= 1 ) then widthOfOne = wp end dxDrawRectangle ( x + ( i * widthOfOneWithBreaks ) + 2, y + 2, widthOfOne - 4, h - 4, tocolor ( 255, 255, 255, 255 ) ); end end end end addEventHandler ( "onClientRender", root, drawProgressBars ); Done sth like this, didn't test it properly, but should work. element dxCreateProgressBar ( int x, int y, int width, int height, int n ) bool dxProgressBarSetProgress ( element ProgressBar, int n ) -- 0 to 1 local p = dxCreateProgressBar ( 0, 0, 500, 50, 4 ); dxProgressBarSetProgress ( p, 0.5 );
  16. I can replace your code with few lines.
  17. function hundredtsixt ( ) guiSetText ( oneMinute, "GodMode On!" ); setTimer ( setElementData, 1000, 1, localPlayer, "godmode", true ); end function hundredtsevt ( ) guiSetText ( oneMinute, "GodMode Off!" ); setTimer ( setElementData, 1000, 1, localPlayer, "godmode", false ); end addEventHandler ( "onClientPlayerDamage", root, function ( ) if ( getElementData ( source, "godmode" ) ) then cancelEvent ( ); end end );
  18. Insert this values which you will select in table like that table = { [1] = gui-element1, [2] = gui-element2, ... [n] = gui-elementn, } And the bind arrows and just add number to variable. Like that. local n = 0; bindKey ( "arrow_d", "down", function ( ) n = n + 1; table [ n ]; -- this is selected element1 end );
  19. Tell me exactly what you want to do.
  20. addEventHandler ( "onClientPlayerDamage", localPlayer, function ( _, id ) if ( id == 54 and getElementModel ( localPlayer ) == 179 ) then -- 54 is the fall id. cancelEvent ( ); end end );
  21. addEventHandler ( "onClientPlayerDamage", localPlayer, function ( _, id ) if ( id == 54 ) then -- 54 is the fall id. cancelEvent ( ); end end ); Also client-side.
×
×
  • Create New...