Jump to content

WhoAmI

Members
  • Posts

    1,248
  • Joined

  • Last visited

Everything posted by WhoAmI

  1. function getPlayerFromPartialName(name) local name = name and string.lower(string.gsub(name, "#%x%x%x%x%x%x", "")) or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = string.lower(string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")) if string.find(name_, name, 1, true) then return player end end end return false end function privateMessage(thePlayer, _, sendToName, ...) local message = table.concat({...}, "") if sendToName then toPlayer = getPlayerFromPartialName(sendToName) outputChatBox ( isElement ( toPlayer ) and tostring( getElementType ( toPlayer ) ) or "false" ); if isElement ( toPlayer ) then if toPlayer ~= thePlayer then if not message == "" then outputChatBox("PM to"..getPlayerName(toPlayer)..":"..message, thePlayer, 255, 255, 0) outputChatBox("PM from"..getPlayerName(thePlayer)..":"..message, toPlayer, 255, 255, 0) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Syntax:/pm [part of name] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You can't speak to your self.", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found.", thePlayer, 255, 0, 0) return false end else outputChatBox("Syntax: /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) What it outputs now?
  2. It is. function pickupShowGarageGUI(thePlayer) if ( source ~= pickup ) then return end showGarageGUI() end addEventHandler ( "onPickupHit", resourceRoot, pickupShowGarageGUI )
  3. Are you sure that you are typing correct part of name?
  4. Move pickup creation from onResourceStart. Make it without any event - put it on top of code.
  5. function getPlayerFromPartialName(name) local name = name and string.lower(string.gsub(name, "#%x%x%x%x%x%x", "")) or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = string.lower(string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")) if string.find(name_, name, 1, true) then return player end end end return false end function privateMessage(thePlayer, _, sendToName, ...) local message = table.concat({...}, "") if sendToName then toPlayer = getPlayerFromPartialName(sendToName) outputChatBox ( isElement ( toPlayer ) and tostring( getElementType ( player ) ) or "false" ); if isElement ( toPlayer ) then if toPlayer ~= thePlayer then if not message == "" then outputChatBox("PM to"..getPlayerName(toPlayer)..":"..message, thePlayer, 255, 255, 0) outputChatBox("PM from"..getPlayerName(thePlayer)..":"..message, toPlayer, 255, 255, 0) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Syntax:/pm [part of name] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You can't speak to your self.", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found.", thePlayer, 255, 0, 0) return false end else outputChatBox("Syntax: /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) Tell me if it outputs "player" or "false" in chatbox.
  6. Did you add getPlayerFromPartialName function name before? 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
  7. function privateMessage(thePlayer, _, sendToName, ...) local message = table.concat({...}, "") if id then target = getPlayerFromID(id) if target == false or target == nil then outputChatBox("That id has not conencted", player, 255, 0, 0) return end end if sendToName then if (getPlayerFromPartialName(sendToName)) then toPlayer = (getPlayerFromPartialName(sendToName)) if not(toPlayer == thePlayer) then if not message == "" then outputChatBox("PM to"..getPlayerName(toPlayer)..":"..message, thePlayer, 255, 255, 0) outputChatBox("PM from"..getPlayerName(thePlayer)..":"..message, toPlayer, 255, 255, 0) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Syntax:/pm [part of name]/ [id] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You can't speak to your self.", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found.", thePlayer, 255, 0, 0) return false end else outputChatBox("Syntax: /pm [part of name] /[id] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage)
  8. In my opinion, race (multigamemode, whatever) is very common gamemode this days.
  9. Pickup has to be created before you attach it to onPickupHit event.
  10. Maybe you are creating pickup after attaching event to function? I mean pickup's function is created earlier than pickup.
  11. local limit = 5 if ( #teamName > limit ) then -- length is too big else -- its okay end
  12. function radar ( player, md ) if getElementType ( player ) ~= "player" or not md then return end if not getElementData(source, "getTurfGang") then return end local t = turfElement[source] if type(t) ~= "table" then return end local turf,area,id = unpack(t) if turf and area and source == turf then local playerGang = getElementData ( player, "gang" ) local turfGang = executeSQLQuery("SELECT GangOwner FROM Turf_System WHERE Turfs=?", "Turf["..tostring(id).."]" ) if ( turfGang[1].GangOwner == playerGang ) then if language == "Spanish" then outputChatBox("Este territorio ya pertenece a "..turfGang[1].GangOwner or "Nadie", player, 0, 255, 0, false) else outputChatBox("This territory already belongs to "..turfGang[1].GangOwner or "None", player, 0, 255, 0, false) end else if not getPlayerTeam(player) then return end local team = getPlayerTeam ( player ) if ( getTeamName( team ) == "Alianza" ) or ( getTeamName( team ) == "Anarquía" ) then local playerGang = getElementData ( player, "gang" ) if ( isTimer ( turfTimer[source] ) ) then return end if ( playerGang ) then local r, g, b = unpack ( exports [ "gang_system" ]:getGangColor ( playerGang ) ) setRadarAreaFlashing ( area, true ) if turfGang[1].GangOwner ~= "Nadie" then if language == "Spanish" then outputChatBox("Entraste en la zona de "..turfGang[1].GangOwner..". Espera 2 minutos y la conquistarás.", player, 0, 255, 0, false) else outputChatBox("You enter into de "..turfGang[1].GangOwner.."'s turf zone. Wait 2 minutes to capture the turf and win 4k", player, 0, 255, 0, false) end else if language == "Spanish" then outputChatBox("¡Esta zona no pertenece a nadie, quédate aquí y conquistarás esta zona para el clan!", player, 0, 255, 0, false) else outputChatBox("This turf do not belong to anyone. Wait 2 minutes to capture the turf and win 4k", player, 0, 255, 0, false) end end turfTimer[source] = setTimer ( function ( ) local beachTurfCplayers = getElementColShape ( turf ) local players = getElementsWithinColShape ( turf, "player" ) setRadarAreaColor ( area, tonumber(r), tonumber(g), tonumber(b), 175 ) for _, player in ipairs ( players ) do if getElementData(player, "gang") == playerGang then if language == "Spanish" then outputChatBox("¡Tu clan ha conquistado la base!", player, 0, 255, 0, false) else outputChatBox("Congratulations. You capture the turf. +4K!", player, 0, 255, 0, false) end triggerClientEvent("onTakeTurf", player) executeSQLQuery("UPDATE Turf_System SET GangOwner=?,r=?,g=?,b=? WHERE Turfs=?", playerGang, tonumber(r), tonumber(g), tonumber(b), "Turf["..tostring(id).."]" ) -- setElementData ( turf, "getTurfGang", playerGang ) end end setRadarAreaFlashing ( area, false ) end ,120000, 1) -- 120000 end end end end end addEventHandler ( "onColShapeHit", resourceRoot, radar )
  13. WhoAmI

    Help!

    Guys c'mon, really? Your helping is going bad way. Probably, resource will start earlier than player will log in, so in this case we'll need to use onPlayerLogin s-side event. teamplayer = createTeam("Jugadores", 255, 255, 255) addEventHandler("onPlayerLogin", root, function ( _, account ) if isGuestAccount(account) then return end local accountName = getAccountName(account) if not isObjectInACLGroup("user."..accountName, aclGetGroup("Anarguia")) or not isObjectInACLGroup("user."..accountName, aclGetGroup("Alianza")) then setPlayerTeam(source, teamplayer) end end )
  14. Saving works fine, but your resource is reseting score by itself. I don't have that much time to edit it.
  15. Send here your drift script and I will test it.
  16. Are you sure? Any errors? Make sure that you restarted resource. I made a simulation with tables and adding values and it should work. Made it other way: -- 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 )" ); outputDebugString ( "connected" ); else outputDebugString ( "not connected" ); 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 local data = fromJSON ( check[1]["data"] ); if ( data ) then for n, v in pairs ( t ) do data[n] = tonumber ( data[n] ) + tonumber ( v ); end end dbQuery ( connection, "UPDATE `drift` SET `data`=? WHERE `account`=?", toJSON ( data ), accName ); -- if yes updating elseif ( #check == 0 ) then dbQuery ( connection, "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 );
  17. -- 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 )" ); outputDebugString ( "connected" ); else outputDebugString ( "not connected" ); 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 for k, v in pairs ( fromJSON ( check[1]["data"] ) ) do t[k] = ( tonumber ( t[k] ) + tonumber ( v ) ); end dbQuery ( connection, "UPDATE `drift` SET `data`=? WHERE `account`=?", toJSON ( t ), accName ); -- if yes updating elseif ( #check == 0 ) then dbQuery ( connection, "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 ); Well, it should work imo.
  18. Did something bad, replace whole code with that -- 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 )" ); outputDebugString ( "connected" ); else outputDebugString ( "not connected" ); 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 for k, v in pairs ( fromJSON ( check[1]["data"] ) ) do t[k] = ( tonumber ( t[k] ) + tonumber ( v ) ); end dbQuery ( connection, "UPDATE `drift` SET `data`=? WHERE `account`=?", toJSON ( t ), accName ); -- if yes updating elseif ( #check == 0 ) then dbQuery ( connection, "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 ); Again updated.
  19. 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 )" ); outputDebugString ( "connected" ); else outputDebugString ( "not connected" ); end -- creating connection and if true creates column if not exist end ); When you start resource check what debug says ("connected" or "not connected").
  20. Replace this whole code with mine and add it to meta. Drift_DB.db can't have content. It has to be clear.
  21. What's the content of drft_db.lua?
  22. U didn't add 'drft_db.lua' to meta.
  23. How are saved drift points? I mean getElementData in this case. Also, show me your meta file and print screen of folder where "Drift_DB.db" is.
  24. rubbish* , nvm Thank you, mr. master of English. @spoty right. Create 'Drift_DB.db' and add it to meta.
×
×
  • Create New...