-
Posts
1,546 -
Joined
-
Last visited
Everything posted by Dimos7
-
I think need setPlayerNametagShowing
-
guiMemoSetReadOnly(edit_login)
-
Because in client side it for each localPlayer
-
You change the password and you need put it there also try connext with browser localhost/phpmyadmin also post the line here
-
--- Client Side GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, radiobutton = {} } GUIEditor.window[1] = guiCreateWindow(190, 76, 645, 642, "Vehicle Spawn by xSet", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(10, 20, 626, 613, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Vehicles", GUIEditor.tabpanel[1]) GUIEditor.button[1] = guiCreateButton(40, 55, 101, 91, "Patriot", false, GUIEditor.tab[1]) GUIEditor.button[2] = guiCreateButton(260, 55, 101, 91, "Boat", false, GUIEditor.tab[1]) GUIEditor.button[3] = guiCreateButton(150, 55, 101, 91, "Bobcat", false, GUIEditor.tab[1]) GUIEditor.button[4] = guiCreateButton(260, 155, 101, 91, "Coach", false, GUIEditor.tab[1]) GUIEditor.button[5] = guiCreateButton(150, 155, 101, 91, "Bike", false, GUIEditor.tab[1]) GUIEditor.button[6] = guiCreateButton(40, 155, 101, 91, "Sanchez", false, GUIEditor.tab[1]) GUIEditor.button[7] = guiCreateButton(40, 255, 101, 91, "Barracks", false, GUIEditor.tab[1]) GUIEditor.button[8] = guiCreateButton(150, 255, 101, 91, "Maverick", false, GUIEditor.tab[1]) GUIEditor.button[9] = guiCreateButton(260, 255, 101, 91, "Police Maverick", false, GUIEditor.tab[1]) GUIEditor.button[10] = guiCreateButton(370, 55, 101, 91, "Quad Bike", false, GUIEditor.tab[1]) GUIEditor.button[11] = guiCreateButton(370, 155, 101, 91, "Camper", false, GUIEditor.tab[1]) GUIEditor.button[12] = guiCreateButton(370, 255, 101, 91, "LSPD", false, GUIEditor.tab[1]) GUIEditor.button[13] = guiCreateButton(480, 255, 101, 91, "Trator", false, GUIEditor.tab[1]) GUIEditor.button[14] = guiCreateButton(480, 155, 101, 91, "Regina", false, GUIEditor.tab[1]) GUIEditor.button[15] = guiCreateButton(480, 55, 101, 91, "Dodo", false, GUIEditor.tab[1]) GUIEditor.button[16] = guiCreateButton(40, 355, 101, 91, "Clover", false, GUIEditor.tab[1]) GUIEditor.button[17] = guiCreateButton(480, 355, 101, 91, "Mesa", false, GUIEditor.tab[1]) GUIEditor.button[18] = guiCreateButton(40, 475, 541, 91, "Spawn Vehicle", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(220, 435, 41, 20, "30", false, GUIEditor.tab[1]) GUIEditor.edit[2] = guiCreateEdit(430, 435, 41, 20, "1", false, GUIEditor.tab[1]) GUIEditor.edit[3] = guiCreateEdit(290, 435, 41, 20, "4", false, GUIEditor.tab[1]) GUIEditor.edit[4] = guiCreateEdit(150, 435, 41, 20, "16", false, GUIEditor.tab[1]) GUIEditor.edit[5] = guiCreateEdit(360, 435, 41, 20, "1", false, GUIEditor.tab[1]) GUIEditor.edit[6] = guiCreateEdit(160, 385, 161, 20, "Quad Bike", false, GUIEditor.tab[1]) GUIEditor.edit[7] = guiCreateEdit(280, 385, 41, 20, "471", false, GUIEditor.tab[1]) GUIEditor.radiobutton[1] = guiCreateRadioButton(335, 375, 161, 20, "Permanent Spawn", false, GUIEditor.tab[1]) GUIEditor.radiobutton[2] = guiCreateRadioButton(335, 395, 161, 20, "Temporary Spawn", false, GUIEditor.tab[1]) guiRadioButtonSetSelected(GUIEditor.radiobutton[2], true) GUIEditor.label[1] = guiCreateLabel(259, 354, 150, 21, "Vehicle Information:", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(155, 415, 41, 16, "Slots:", false, GUIEditor.tab[1]) GUIEditor.label[3] = guiCreateLabel(228, 415, 31, 16, "Fuel:", false, GUIEditor.tab[1]) GUIEditor.label[4] = guiCreateLabel(292, 415, 41, 16, "Tires", false, GUIEditor.tab[1]) GUIEditor.label[5] = guiCreateLabel(360, 415, 51, 16, "Engines:", false, GUIEditor.tab[1]) GUIEditor.label[6] = guiCreateLabel(432, 415, 51, 16, "Tanks:", false, GUIEditor.tab[1]) GUIEditor.label[7] = guiCreateLabel(241, 24, 261, 21, "Select a Vehicle To Spawn :", false, GUIEditor.tab[1]) guiSetFont(GUIEditor.label[7], "clear-normal") GUIEditor.tab[2] = guiCreateTab("Editados", GUIEditor.tabpanel[1]) GUIEditor.button[19] = guiCreateButton(40, 55, 101, 91, "Leviathan", false, GUIEditor.tab[2]) GUIEditor.button[20] = guiCreateButton(150, 55, 101, 91, "Rustler", false, GUIEditor.tab[2]) GUIEditor.button[21] = guiCreateButton(260, 55, 101, 91, "Maverick", false, GUIEditor.tab[2]) GUIEditor.button[22] = guiCreateButton(370, 55, 101, 91, "Police Maverick", false, GUIEditor.tab[2]) GUIEditor.button[23] = guiCreateButton(480, 55, 101, 91, "Raindance", false, GUIEditor.tab[2]) GUIEditor.button[24] = guiCreateButton(40, 155, 101, 91, "Shamal", false, GUIEditor.tab[2]) GUIEditor.button[25] = guiCreateButton(150, 155, 101, 91, "News Maverick", false, GUIEditor.tab[2]) GUIEditor.button[26] = guiCreateButton(260, 155, 101, 91, "Phoenix", false, GUIEditor.tab[2]) GUIEditor.button[27] = guiCreateButton(480, 255, 101, 91, "Bobcat", false, GUIEditor.tab[2]) GUIEditor.button[28] = guiCreateButton(150, 255, 101, 91, "Ambulance", false, GUIEditor.tab[2]) GUIEditor.button[29] = guiCreateButton(40, 255, 101, 91, "Super GT", false, GUIEditor.tab[2]) GUIEditor.button[30] = guiCreateButton(370, 255, 101, 91, "Bravura", false, GUIEditor.tab[2]) GUIEditor.button[31] = guiCreateButton(260, 255, 101, 91, "Sabre", false, GUIEditor.tab[2]) GUIEditor.button[32] = guiCreateButton(370, 155, 101, 91, "FBI Truck", false, GUIEditor.tab[2]) GUIEditor.button[33] = guiCreateButton(480, 155, 101, 91, "Infernus", false, GUIEditor.tab[2]) GUIEditor.button[34] = guiCreateButton(40, 355, 101, 91, "Barracks", false, GUIEditor.tab[2]) GUIEditor.button[35] = guiCreateButton(480, 355, 101, 91, "Hotring Racer", false, GUIEditor.tab[2]) GUIEditor.button[36] = guiCreateButton(40, 475, 541, 91, "Spawn Vehicle", false, GUIEditor.tab[2]) GUIEditor.edit[8] = guiCreateEdit(220, 435, 41, 20, "100", false, GUIEditor.tab[2]) GUIEditor.edit[9] = guiCreateEdit(430, 435, 41, 20, "1", false, GUIEditor.tab[2]) GUIEditor.edit[10] = guiCreateEdit(290, 435, 41, 20, "4", false, GUIEditor.tab[2]) GUIEditor.edit[11] = guiCreateEdit(150, 435, 41, 20, "100", false, GUIEditor.tab[2]) GUIEditor.edit[12] = guiCreateEdit(360, 435, 41, 20, "1", false, GUIEditor.tab[2]) GUIEditor.edit[13] = guiCreateEdit(160, 385, 161, 20, "Phoenix", false, GUIEditor.tab[2]) GUIEditor.edit[14] = guiCreateEdit(280, 385, 41, 20, "603", false, GUIEditor.tab[2]) GUIEditor.radiobutton[3] = guiCreateRadioButton(335, 375, 161, 20, "Permanent Spawn", false, GUIEditor.tab[2]) guiRadioButtonSetSelected(GUIEditor.radiobutton[3], true) GUIEditor.radiobutton[4] = guiCreateRadioButton(335, 395, 161, 20, "Temporary Spawn", false, GUIEditor.tab[2]) GUIEditor.label[8] = guiCreateLabel(259, 355, 150, 21, "Vehicle Information:", false, GUIEditor.tab[2]) GUIEditor.label[9] = guiCreateLabel(155, 415, 41, 16, "Slots:", false, GUIEditor.tab[2]) GUIEditor.label[10] = guiCreateLabel(228, 415, 31, 16, "Fuel:", false, GUIEditor.tab[2]) GUIEditor.label[11] = guiCreateLabel(292, 415, 41, 16, "Tires", false, GUIEditor.tab[2]) GUIEditor.label[12] = guiCreateLabel(360, 415, 51, 16, "Engines:", false, GUIEditor.tab[2]) GUIEditor.label[13] = guiCreateLabel(432, 415, 51, 16, "Tanks:", false, GUIEditor.tab[2]) GUIEditor.label[14] = guiCreateLabel(229, 24, 261, 21, "Select a Vehicle To Spawn :", false, GUIEditor.tab[2]) guiSetFont(GUIEditor.label[14], "clear-normal") GUIEditor.tab[3] = guiCreateTab("Editados", GUIEditor.tabpanel[1]) GUIEditor.button[37] = guiCreateButton(40, 55, 101, 91, "PCJ600", false, GUIEditor.tab[3]) GUIEditor.button[38] = guiCreateButton(150, 55, 101, 91, "Freeway", false, GUIEditor.tab[3]) GUIEditor.button[39] = guiCreateButton(260, 55, 101, 91, "Sanchez", false, GUIEditor.tab[3]) GUIEditor.button[40] = guiCreateButton(370, 55, 101, 91, "Patriot", false, GUIEditor.tab[3]) GUIEditor.button[41] = guiCreateButton(480, 55, 101, 91, "Quad", false, GUIEditor.tab[3]) GUIEditor.button[42] = guiCreateButton(40, 155, 101, 91, "Camper", false, GUIEditor.tab[3]) GUIEditor.button[43] = guiCreateButton(150, 155, 101, 91, "Mesa", false, GUIEditor.tab[3]) GUIEditor.button[44] = guiCreateButton(260, 155, 101, 91, "Bike", false, GUIEditor.tab[3]) GUIEditor.button[45] = guiCreateButton(370, 155, 101, 91, "HPV1000", false, GUIEditor.tab[3]) GUIEditor.button[46] = guiCreateButton(480, 155, 101, 91, "FBI Rancher", false, GUIEditor.tab[3]) GUIEditor.button[47] = guiCreateButton(40, 255, 101, 91, "Police", false, GUIEditor.tab[3]) GUIEditor.button[48] = guiCreateButton(150, 255, 101, 91, "Tank", false, GUIEditor.tab[3]) GUIEditor.button[49] = guiCreateButton(260, 255, 101, 91, "Landstalker", false, GUIEditor.tab[3]) GUIEditor.button[50] = guiCreateButton(370, 255, 101, 91, "Alpha", false, GUIEditor.tab[3]) GUIEditor.button[51] = guiCreateButton(480, 255, 101, 91, "Buffalo", false, GUIEditor.tab[3]) GUIEditor.button[52] = guiCreateButton(40, 355, 101, 91, "NRG-500", false, GUIEditor.tab[3]) GUIEditor.button[53] = guiCreateButton(480, 355, 101, 91, "Bullet", false, GUIEditor.tab[3]) GUIEditor.button[54] = guiCreateButton(40, 475, 541, 91, "Spawn Vehicle", false, GUIEditor.tab[3]) GUIEditor.edit[15] = guiCreateEdit(220, 435, 41, 20, "100", false, GUIEditor.tab[3]) GUIEditor.edit[16] = guiCreateEdit(430, 435, 41, 20, "1", false, GUIEditor.tab[3]) GUIEditor.edit[17] = guiCreateEdit(290, 435, 41, 20, "2", false, GUIEditor.tab[3]) GUIEditor.edit[18] = guiCreateEdit(150, 435, 41, 20, "100", false, GUIEditor.tab[3]) GUIEditor.edit[19] = guiCreateEdit(360, 435, 41, 20, "1", false, GUIEditor.tab[3]) GUIEditor.edit[20] = guiCreateEdit(160, 385, 161, 20, "HPV1000", false, GUIEditor.tab[3]) GUIEditor.edit[21] = guiCreateEdit(280, 385, 41, 20, "523", false, GUIEditor.tab[3]) GUIEditor.radiobutton[5] = guiCreateRadioButton(335, 375, 161, 20, "Permanent Spawn", false, GUIEditor.tab[3]) GUIEditor.radiobutton[6] = guiCreateRadioButton(335, 395, 161, 20, "Temporary Spawn", false, GUIEditor.tab[3]) guiRadioButtonSetSelected(GUIEditor.radiobutton[6], true) GUIEditor.label[15] = guiCreateLabel(259, 355, 150, 21, "Vehicle Information:", false, GUIEditor.tab[3]) GUIEditor.label[16] = guiCreateLabel(155, 415, 41, 16, "Slots:", false, GUIEditor.tab[3]) GUIEditor.label[17] = guiCreateLabel(228, 415, 31, 16, "Fuel:", false, GUIEditor.tab[3]) GUIEditor.label[18] = guiCreateLabel(292, 415, 41, 16, "Tires:", false, GUIEditor.tab[3]) GUIEditor.label[19] = guiCreateLabel(360, 415, 51, 16, "Engines:", false, GUIEditor.tab[3]) GUIEditor.label[20] = guiCreateLabel(432, 415, 51, 16, "Tanks:", false, GUIEditor.tab[3]) GUIEditor.label[21] = guiCreateLabel(229, 24, 261, 21, "Select a Vehicle To Spawn :", false, GUIEditor.tab[3]) guiSetFont(GUIEditor.label[21], "clear-normal") function guiOpen() guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end bindKey("F4", "down", guiOpen) addEventHandler("onClientGUIClick", root, function(button, state) if source == GUIEditor.button[1] and button == "left" and state == "up" then if guiRadioButtonGetSelected(GUIEditor.radiobutton[1]) then triggerServerEvent("makePremVehicle", localPlayer, "Patriot") elseif guiRadioButtonGetSelected(GUIEditor.radiobutton[2]) then triggerServerEvent("makeTempVehicle", localPlayer, "Patriot") end end end) -- Server Side function makePermVehicle(thePlayer,vehicleName) local x, y, z = getElementPosition(thePlayer) local r = getPedRotation(thePlayer) y = y + 5 r= r + 90 vehicle = createVehicle(getVehicleModelFromName(vehicleName), x, y, z, 0, 0 , r) end addEvent("makePermVehicle", true) addEventHandler("makePermVehicle", root, makePermVehicle) function makeTempVehicle(thePlayer,vehicleName) local x, y, z = getElementPosition(thePlayer) local r = getPedRotation(thePlayer) y = y + 5 r= r + 90 vehicle = createVehicle(getVehicleModelFromName(vehicleName), x, y, z, 0, 0 , r) setTimer(function() destoryElement(vehicle) end, 5000, 1) end addEvent("makeTempVehicle", true) addEventHandler("makeTempVehicle", root, makeTempVehicle)
-
sw, sh = guiGetScreenSize() sx, sy = sw/1366, sh/768 function drawStuff() dxDrawRectangle(0*sx, (i*45)-ground.scroll*sy,43*sx, 43*sy, tocolor(255, 255, 255, 230)) dxDrawImage(0*sx, (i*45)-ground.scroll*sy, 43*sx, 43*sy, "Imagenes/Inventarior/Iconos/"..v[2]..".png", sx*0, sy*0, sx*0, tocolor(255, 255, 255)) dxDrawRectangle(43*sx, (i*45)-ground.scroll*sy, 196*sx, 43*sy, tocolor(255, 255, 255, 200)) dxDrawLine(0*sx, (i*45+42)-ground.scroll*sy, 513*sx, (i*45+42)-ground.scroll*sy, tocolor(255, 255, 255, 230), sx*2, false) dxDrawText(translateLocalization(v[2]), 48*sx, (i*45)-ground.scroll*sy, 194*sx, (i*45+45)-ground.scroll*sy, tocolor(255, 255, 255), sx*1, "default", "left", "center", false, false, false. false, false, sx*0, sy*0, sx*0) end addEventHandler("onClientRender", root, drawStuff) try this
-
local locations = { -- x, y, z, rotation z { 1825.94, -872.12, 63, 90 }, { 1365.44, -640.1, 108.4, -90 }, { 1037.28, -724.34, 118.05, 45 }, { 684.22, -441.59, 16.34, 93 }, { 215.46, -230.01, 1.78, -90 }, { 513.48, -116.15, 38.16, 330 }, { 1105.34, -307.32, 73.69, -90 }, } local vehicleModels = { 402, 411, 414, 415, 434, 440, 442, 444, 451, 455, 456, 475, 477, 489, 494, 495, 498, 499, 502, 503, 404, 506, 522 } local crimainlTheftVehicle = nil local criminalTheftBlip = nil local last_i = 0 local CriminalTheftVehicleLabel = nil function makeCriminalTheftVehicle ( ) if ( isElement ( crimainlTheftVehicle ) ) then if ( getVehicleController ( crimainlTheftVehicle ) ) then return end destroyElement ( crimainlTheftVehicle ) end if ( isElement ( criminalTheftBlip ) ) then destroyElement ( criminalTheftBlip ) end if ( isElement ( CriminalTheftVehicleLabel ) ) then destroyElement ( CriminalTheftVehicleLabel ) end if ( isTimer ( CriminalVehicleTheftTimer ) ) then killTimer ( CriminalVehicleTheftTimer ) end local i = math.random ( #locations ) if ( i == last_i ) then while ( i == last_i ) do i = math.random ( #locations ) end end local data = locations[i] local carModel = vehicleModels[math.random ( #vehicleModels )] crimainlTheftVehicle = createVehicle ( carModel, data[1], data[2], data[3], 0, 0, data[4] ) CriminalTheftVehicleLabel = create3DText ( "Criminal Theft Vehicle", { 0, 0, 1 }, { 255, 0, 0 }, criminalTheftVehicle ) criminalTheftBlip = createBlipAttachedTo ( crimainlTheftVehicle, 12 ) addEventHandler ( "onVehicleStartEnter", crimainlTheftVehicle, function ( p, seat ) if ( seat == 0 ) then if ( not getPlayerTeam ( p ) or getTeamName(getPlayerTeam(p))~= ("Criminals" or "Terrorists")) then cancelEvent ( ) exports['NGMessages']:sendClientMessage ( "You cannot enter this vehicle.", p, 255, 0, 0 ) end end end ) addEventHandler ( 'onVehicleEnter', crimainlTheftVehicle, function ( p, seat ) if ( seat == 0 ) then outputTeamMessage ( getPlayerName ( p ).." has entered the "..getVehicleNameFromModel ( getElementModel ( source ) ).."!", "Criminals", 255, 255, 0 ) exports['NGMessages']:sendClientMessage ( "Take this vehicle to an avalible drop off point; The checkered flags on your map.", p, 0, 255, 0 ) triggerClientEvent ( p, 'NGJobs:Criminal:Theft:setWaypointsVisible', p, true ) end end ) addEventHandler ( 'onVehicleExit', crimainlTheftVehicle, function ( p, seat ) if ( seat == 0 ) then outputTeamMessage ( getPlayerName ( p ).." has left the vehicle!", "Criminals", 0, 255, 0 ) triggerClientEvent ( p, "NGJobs:Criminal:Theft:setWaypointsVisible", p, false ) end end ) addEventHandler ( 'onVehicleExplode', crimainlTheftVehicle, function ( ) if ( isElement ( criminalTheftBlip ) ) then destroyElement ( criminalTheftBlip ) end if ( isElement ( CriminalTheftVehicleLabel ) ) then destroyElement ( CriminalTheftVehicleLabel ) end outputTeamMessage ( "The "..getVehicleNameFromModel ( getElementModel ( source ) ).." has exploded.", "Criminals", 255, 0, 0 ) if ( isElement ( crimainlTheftVehicle ) ) then destroyElement ( crimainlTheftVehicle ) end triggerClientEvent ( root, "NGJobs:Criminal:Theft:setWaypointsVisible", root, false ) if ( isTimer ( CriminalVehicleTheftTimer ) ) then killTimer ( CriminalVehicleTheftTimer ) end CriminalVehicleTheftTimer = setTimer ( makeCriminalTheftVehicle, 1000*math.random ( 200, 500 ), 1 ) end ) local city = getZoneName ( data[1], data[2], data[3], true ) local area = getZoneName ( data[1], data[2], data[3] ) local vehName = getVehicleNameFromModel ( carModel ) for i, v in ipairs ( getPlayersInTeam ( getTeamFromName ( "Criminals" or "Terrorists" ) ) ) do exports['NGMessages']:sendClientMessage ( "There is a "..vehName.." available for pickup in "..area..", "..city.."! Be the first one! (The 'C' blip)", v, 255, 50, 50 ) end end addEvent ( "NGJobs:Criminal:Theft:onPlayerCaptureVehicle", true ) addEventHandler ( "NGJobs:Criminal:Theft:onPlayerCaptureVehicle", root, function ( ) if ( isElement ( crimainlTheftVehicle ) ) then destroyElement ( crimainlTheftVehicle ) end if ( isElement ( criminalTheftBlip ) ) then destroyElement ( criminalTheftBlip ) end if ( isElement ( CriminalTheftVehicleLabel ) ) then destroyElement ( CriminalTheftVehicleLabel ) end if ( isTimer ( CriminalVehicleTheftTimer ) ) then killTimer ( CriminalVehicleTheftTimer ) end local cash = math.random ( 5000, 15000 ) outputTeamMessage ( getPlayerName ( source ).." has captured the vehicle and made $"..cash, "Criminals" or "Terrorists", 255, 255, 0 ) exports['NGMessages']:sendClientMessage ( "Nice job!", source, 0, 255, 0 ) givePlayerMoney ( source, cash ) updateJobColumn ( getAccountName ( getPlayerAccount ( source ) ), "CriminalActions", "AddOne" ) CriminalVehicleTheftTimer = setTimer ( makeCriminalTheftVehicle, 1000*math.random ( 200, 500 ), 1 ) exports['NGLogs']:outputActionLog ( getPlayerName ( source ).." captured the criminal theft vehicle" ) giveWantedPoints ( source, math.random ( 70, 150 ) ) end ) setTimer ( function ( ) makeCriminalTheftVehicle ( ) CriminalVehicleTheftTimer = setTimer ( makeCriminalTheftVehicle, 300000, 0 ) end, 1000, 1 ) Hello there i have a problem i try to shovel it but i can't fiout why its not working when i am on criminals team work i can enter the vehicle and theft it but not with terrorists can someone help me
-
local conection = exports.sql:getConnection() function makePlayerVehicle(player, command, model, modelName) if not model or modelName then return outputChatBox("SYNATX:/ "..command.."[model id]", player, 255, 0, 0) end local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) local letter1 = string.char(math.random(65,90)) local letter2 = string.char(math.random(65,90)) local plate = letter1 .. letter2 .. math.random(0, 9) .. " " .. math.random(1000, 9999) local interior = getElementInterior(player) local dimension = getElementDimension(player) local owner = getPlayerName(player) y = y + 5 rz = rz + 90 dbExec(conection,"INSERT INTO vehicles (model, x, y, z, rotx, roty, rotz, currx, curry, currz, currrx, currry, currrz, color1, color2, color3, color4, plate, owner, dimension, interior, currdimension, currinterior) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",tostring(model),tostring(x),tostring(y),tostring(z),tostring(rx),tostring(ry),tostring(rz),tostring(x), tostring(y), tostring(z), tostring(rx), tostring(ry), tostring(rz), tostring(color1), tostring(color2), tostring(color3), tostring(color4), tostring(plate), owner, tostring(dimension), tostring(interior), tostring(dimension), tostring(interior)) local vehicleOb = createVehicle(model, x, y, z, rx, ry, rz, plate) local col = { getVehicleColor(vehicleOb, true)} local color1 = toJSON({col[1], col[2], col[3]}) local color2 = toJSON({col[4], col[5], col[6]}) local color3 = toJSON({col[7], col[8], col[9]}) local color4 = toJSON({col[10], col[11], col[12]}) setElementInterior(vehicleOb, interior) setElementDimension(vehicleob, dimension) setElementData(player, "vehicle", vehicleOb) setElementData(vehicleOb, "owner", owner) dbQuery(function(queryHandler) local results = dbPoll(queryHandler, 0) local vehicle = results[1] setElementData(vehicleOb, "id", vehicle.id) end, conection, "SELECT id FROM vehicles ORDER BY id DESC LIMIT 1") end addCommandHandler("makeveh", makePlayerVehicle, false, false) function loadAllVehicles(queryHandler) local results = dbPoll(queryHandler, 0) for index, vehicle in ipairs(results) do local vehicleOb = createVehicle(vehicle.model, vehicle.currx, vehicle.curry, vehicle.currz, vehicle.currrx, vehicle.currry, vehicle.currrz, vehicle.plate) setElementData(vehicleOb, "id", vehicle.id) local color1 = fromJSON(vehicle.color1) local color2 = fromJSON(vehicle.color2) local color3 = fromJSON(vehicle.color3) local color4 = fromJSON(vehicle.color4) local headlightColors = fromJSON(vehicle.headlights) setVehicleColor(vehicle, color1[1], color1[2], color1[3], color2[1], color2[2], color2[3], color3[1], color3[2], color3[3], color4[1], color4[2], color4[3]) setVehicleHeadLightColor(vehicle, headlightColors[1], headlightColors[2], headlightColors[3]) setElementHealth(vehicle, vehicle.hp) setElementDimension(vehicle, vehicle.currdimension) setElementInterior(vehicle, vehicle.currinterior) setElementData(vehicle, "owner", vehicle.owner) setElementData(vehicle, "engine", vehicle.engine) setVehicleOverrideLights(vehicle, vehicle.lights) setVehicleLocked(vehicle, vehicle.locked) setVehicleSirensOn(vehicle, vehicle.sirens) if vehicle.paintjob ~= 0 then setVehiclePaintjob(vehicle, vehicle.paintjob) end local upgrades = fromJSON(vehicle.upgrades) for slot, upgrade in ipairs(upgrades) do if upgrade and tonumber(upgrade) > 0 then addVehicleUpgrade(vehicle, upgrade) end end local panelStates = fromJSON(vehicle.panelStates) for panel, state in ipairs(panelStates) do setVehiclePanelState(vehicle, panel-1, tonumber(state) or 0) end local doorStates = fromJSON(vehicle.doorStates) for door, state in ipairs(doorStates) do setVehicleDoorState(vehicle, door-1, tonumber(state) or 0) end local wheelStates = fromJSON(vehicle.wheelStates) for wheel, state in ipairs(wheelStates) do setVehicleWheelStates(vehicle, wheel-1, tonumber(state) or 0) end end end addEventHandler("onResourceStart", resourceRoot, function() dbQuery(loadAllVehicles,conection, "SELECT * FROM vehicles") end) addEventHandler("onResourceStop", resourceRoot, function() local vehicles = getElementsByType("vehicle") for index, vehicle in ipairs(vehicles) do local id = getElementData(vehicle, "id") local x, y, z = getElementPosition(vehicle) local rx, ry, rz = getElementRotation(vehicle) local dimension = getElementDimension(vehicle) local interior = getElementInterior(vehicle) local hp = getElementHealth(vehicle) local col = { getVehicleColor(vehicle, true)} local color1 = toJSON( {col[1], col[2], col[3]}) local color2 = toJSON( {col[4], col[5], col[6]}) local color3 = toJSON({col[7], col[8], col[9]}) local color4 = toJSON({col[10], col[11], col[12]}) local paintjob = getVehiclePaintjob(vehicle) local engine = getElementData(vehicle, "engine") local locked = isVehicleLocked(vehicle) and 1 or 0 local lights = getVehicleOverrideLights(vehicle) local sirens = getVehicleSirensOn(vehicle) and 1 or 0 local panel0 = getVehiclePanelState(vehicle, 0) local panel1 = getVehiclePanelState(vehicle, 1) local panel2 = getVehiclePanelState(vehicle, 2) local panel3 = getVehiclePanelState(vehicle, 3) local panel4 = getVehiclePanelState(vehicle, 4) local panel5 = getVehiclePanelState(vehicle, 5) local panel6 = getVehiclePanelState(vehicle, 6) local door0 = getVehicleDoorState(vehicle, 0) local door1 = getVehicleDoorState(vehicle, 1) local door2 = getVehicleDoorState(vehicle, 2) local door3 = getVehicleDoorState(vehicle, 3) local door4 = getVehicleDoorState(vehicle, 4) local door5 = getVehicleDoorState(vehicle, 5) local wheel1, wheel2, wheel3, wheel4 = getVehicleWheelStates(vehicle) local hcol1, hcol2, hcol3 = getVehicleHeadLightColor(vehicle) local panelStates = toJSON({panel0, panel1, panel2, panel3, panel4, panel5, panel6}) local doorStates = toJSON ({door0,door1, door2, door3, door4, door5}) local wheelStates = toJSON({wheel1, wheel2, wheel3, wheel4}) local headlights = toJSON({hcol1, hcol2, hcol3}) dbExec(conection,"UPDATE vehicles SET currx=?, curry=?, currz=?, currrx=?, currry=?, currrz=?, engine=?, locked=?, lights=?, sirens=?, paintob=?, hp=?, color1=?, color2=?, color3=?, color4=?, currdimension =?, currinterior=?, panelStates=?, doorStates=?, wheelStates=?, headlights=?, WHERE id=?",tostring(x),tostring(y),tostring(z),tostring(rx),tostring(ry),tostring(rz), tostring(engine), tostring(lights), tostring(locked), tostring(sirens), tostring(paintjob),tostring(hp),tostring(color1), tostring(color2), tostring(color3), tostring(color4), tostring(dimension), tostring(interior), tostring(panelStates), tostring(doorStates), tostring(wheelStates), tostring(headlights), id) end end) addEventHandler("onVehicleExit", root, function() local id = getElementData(source, "id") local x, y, z = getElementPosition(source) local rx, ry, rz = getElementRotation(source) local dimension = getElementDimension(source) local interior = getElementInterior(source) local hp = getElementHealth(source) local col = {getVehicleColor(source, true)} local color1 = toJSON({col[1], col[2], col[3]}) local color2 = toJSON({col[4], col[5], col[6]}) local color3 = toJSON({col[7], col[8], col[9]}) local color4 = toJSON({col[10], col[11], col[12]}) local paintjob = getVehiclePaintjob(source) local engine = getElementData(source, "engine") local locked = isVehicleLocked(source) and 1 or 0 local lights = getVehicleOverrideLights(source) local sirens = getVehicleSirensOn(source) and 1 or 0 local panel0 = getVehiclePanelState(source, 0) local panel1 = getVehiclePanelState(source, 1) local panel2 = getVehiclePanelState(source, 2) local panel3 = getVehiclePanelState(source, 3) local panel4 = getVehiclePanelState(source, 4) local panel5 = getVehiclePanelState(source, 5) local panel6 = getVehiclePanelState(source, 6) local door0 = getVehicleDoorState(source, 0) local door1 = getVehicleDoorState(source, 1) local door2 = getVehicleDoorState(source, 2) local door3 = getVehicleDoorState(source, 3) local door4 = getVehicleDoorState(source, 4) local door5 = getVehicleDoorState(source, 5) local wheel1, wheel2, wheel3, wheel4 = getVehicleWheelStates(source) local hcol1, hcol2, hcol3 = getVehicleHeadLightColor(source) local panelStates = toJSON( {panel0, panel1, panel2, panel3, panel4, panel5, panel6}) local doorStates = toJSON ( {door0,door1, door2, door3, door4, door5}) local wheelStates = toJSON({wheel1, wheel2, wheel3, wheel4}) local headlights = toJSON({hcol1, hcol2, hcol3}) dbExec(conection,"UPDATE vehicles SET currx=?, curry=?, currz=?, currrx=?, currry=?, currrz=?, engine=?, locked=?, lights=?, sirens=?, paintob=?, hp=?, color1=?, color2=?, color3=?, , color4=? currdimension =?, currinterior=?, panelStates=?, doorStates=?, wheelStates=?,headlights=?, WHERE id=?",tostring(x),tostring(y),tostring(z),tostring(rx),tostring(ry),tostring(rz), tostring(engine), tostring(lights), tostring(locked), tostring(sirens), tostring(paintjob),tostring(hp),tostring(color1), tostring(color2), tostring(color3), tostring(color4), tostring(dimension), tostring(interior), tostring(panelStates), tostring(doorStates), tostring(wheelStates), tostring(headlights), id) end) seems it get nil when the object created idk why also i ahve a error now at sytax of query at 124 near where
-
local conection = exports.sql:getConnection() function makePlayerVehicle(player, command, model, modelName) if not model or modelName then return outputChatBox("SYNATX:/ "..command.."[model id]", player, 255, 0, 0) end local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) local letter1 = string.char(math.random(65,90)) local letter2 = string.char(math.random(65,90)) local plate = letter1 .. letter2 .. math.random(0, 9) .. " " .. math.random(1000, 9999) local interior = getElementInterior(player) local dimension = getElementDimension(player) local owner = getPlayerName(player) local col = { getVehicleColor(vehicleOb, true)} local color1 = toJSON({col[1], col[2], col[3]}) local color2 = toJSON({col[4], col[5], col[6]}) local color3 = toJSON({col[7], col[8], col[9]}) local color4 = toJSON({col[10], col[11], col[12]}) y = y + 5 rz = rz + 90 dbExec(conection,"INSERT INTO vehicles (model, x, y, z, rotx, roty, rotz, currx, curry, currz, currrx, currry, currrz, color1, color2, color3, color4, plate, owner, dimension, interior, currdimension, currinterior) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",tostring(model),tostring(x),tostring(y),tostring(z),tostring(rx),tostring(ry),tostring(rz),tostring(x), tostring(y), tostring(z), tostring(rx), tostring(ry), tostring(rz), tostring(color1), tostring(color2), tostring(color3), tostring(color4), tostring(plate), owner, tostring(dimension), tostring(interior), tostring(dimension), tostring(interior)) local vehicleOb = createVehicle(model, x, y, z, rx, ry, rz, plate) setElementInterior(vehicleOb, interior) setElementDimension(vehicleob, dimension) setElementData(player, "vehicle", vehicleOb) setElementData(vehicleOb, "owner", owner) dbQuery(function(queryHandler) local results = dbPoll(queryHandler, 0) local vehicle = results[1] setElementData(vehicleOb, "id", vehicle.id) end, conection, "SELECT id FROM vehicles ORDER BY id DESC LIMIT 1") end addCommandHandler("makeveh", makePlayerVehicle, false, false) function loadAllVehicles(queryHandler) local results = dbPoll(queryHandler, 0) for index, vehicle in ipairs(results) do local vehicleOb = createVehicle(vehicle.model, vehicle.currx, vehicle.curry, vehicle.currz, vehicle.currrx, vehicle.currry, vehicle.currrz, vehicle.plate) setElementData(vehicleOb, "id", vehicle.id) local color1 = fromJSON(vehicle.color1) local color2 = fromJSON(vehicle.color2) local color3 = fromJSON(vehicle.color3) local color4 = fromJSON(vehicle.color4) local headlightColors = fromJSON(vehicle.headlights) setVehicleColor(vehicle, color1[1], color1[2], color1[3], color2[1], color2[2], color2[3], color3[1], color3[2], color3[3], color4[1], color4[2], color4[3]) setVehicleHeadLightColor(vehicle, headlightColors[1], headlightColors[2], headlightColors[3]) setElementHealth(vehicle, vehicle.hp) setElementDimension(vehicle, vehicle.currdimension) setElementInterior(vehicle, vehicle.currinterior) setElementData(vehicle, "owner", vehicle.owner) setElementData(vehicle, "engine", vehicle.engine) setVehicleOverrideLights(vehicle, vehicle.lights) setVehicleLocked(vehicle, vehicle.locked) setVehicleSirensOn(vehicle, vehicle.sirens) if vehicle.paintjob ~= 0 then setVehiclePaintjob(vehicle, vehicle.paintjob) end local upgrades = fromJSON(vehicle.upgrades) for slot, upgrade in ipairs(upgrades) do if upgrade and tonumber(upgrade) > 0 then addVehicleUpgrade(vehicle, upgrade) end end local panelStates = fromJSON(vehicle.panelStates) for panel, state in ipairs(panelStates) do setVehiclePanelState(vehicle, panel-1, tonumber(state) or 0) end local doorStates = fromJSON(vehicle.doorStates) for door, state in ipairs(doorStates) do setVehicleDoorState(vehicle, door-1, tonumber(state) or 0) end local wheelStates = fromJSON(vehicle.wheelStates) for wheel, state in ipairs(wheelStates) do setVehicleWheelStates(vehicle, wheel-1, tonumber(state) or 0) end end end addEventHandler("onResourceStart", resourceRoot, function() dbQuery(loadAllVehicles,conection, "SELECT * FROM vehicles") end) addEventHandler("onResourceStop", resourceRoot, function() local vehicles = getElementsByType("vehicle") for index, vehicle in ipairs(vehicles) do local id = getElementData(vehicle, "id") local x, y, z = getElementPosition(vehicle) local rx, ry, rz = getElementRotation(vehicle) local dimension = getElementDimension(vehicle) local interior = getElementInterior(vehicle) local hp = getElementHealth(vehicle) local col = { getVehicleColor(vehicle, true)} local color1 = toJSON( {col[1], col[2], col[3]}) local color2 = toJSON( {col[4], col[5], col[6]}) local color3 = toJSON({col[7], col[8], col[9]}) local color4 = toJSON({col[10], col[11], col[12]}) local paintjob = getVehiclePaintjob(vehicle) local engine = getElementData(vehicle, "engine") local locked = isVehicleLocked(vehicle) and 1 or 0 local lights = getVehicleOverrideLights(vehicle) local sirens = getVehicleSirensOn(vehicle) and 1 or 0 local panel0 = getVehiclePanelState(vehicle, 0) local panel1 = getVehiclePanelState(vehicle, 1) local panel2 = getVehiclePanelState(vehicle, 2) local panel3 = getVehiclePanelState(vehicle, 3) local panel4 = getVehiclePanelState(vehicle, 4) local panel5 = getVehiclePanelState(vehicle, 5) local panel6 = getVehiclePanelState(vehicle, 6) local door0 = getVehicleDoorState(vehicle, 0) local door1 = getVehicleDoorState(vehicle, 1) local door2 = getVehicleDoorState(vehicle, 2) local door3 = getVehicleDoorState(vehicle, 3) local door4 = getVehicleDoorState(vehicle, 4) local door5 = getVehicleDoorState(vehicle, 5) local wheel1, wheel2, wheel3, wheel4 = getVehicleWheelStates(vehicle) local hcol1, hcol2, hcol3 = getVehicleHeadLightColor(vehicle) local panelStates = toJSON({panel0, panel1, panel2, panel3, panel4, panel5, panel6}) local doorStates = toJSON ({door0,door1, door2, door3, door4, door5}) local wheelStates = toJSON({wheel1, wheel2, wheel3, wheel4}) local headlights = toJSON({hcol1, hcol2, hcol3}) dbExec(conection,"UPDATE vehicles SET currx=?, curry=?, currz=?, currrx=?, currry=?, currrz=?, engine=?, locked=?, lights=?, sirens=?, paintob=?, hp=?, color1=?, color2=?,, color3=?, color4=?, currdimension =?, currinterior=?, panelStates=?, doorStates=?, wheelStates=?,headlights=?, WHERE id=?",tostring(x),tostring(y),tostring(z),tostring(rx),tostring(ry),tostring(rz), tostring(engine), tostring(lights), tostring(locked), tostring(sirens), tostring(paintjob),tostring(hp),tostring(color1), tostring(color2), tostring(color3), tostring(color4), tostring(dimension), tostring(interior), tostring(panelStates), tostring(doorStates), tostring(wheelStates), tostring(headlights), id) end end) addEventHandler("onVehicleExit", root, function() local id = getElementData(source, "id") local x, y, z = getElementPosition(source) local rx, ry, rz = getElementRotation(source) local dimension = getElementDimension(source) local interior = getElementInterior(source) local hp = getElementHealth(source) local col = {getVehicleColor(source, true)} local color1 = toJSON({col[1], col[2], col[3]}) local color2 = toJSON({col[4], col[5], col[6]}) local color3 = toJSON({col[7], col[8], col[9]}) local color4 = toJSON({col[10], col[11], col[12]}) local paintjob = getVehiclePaintjob(source) local engine = getElementData(source, "engine") local locked = isVehicleLocked(source) and 1 or 0 local lights = getVehicleOverrideLights(source) local sirens = getVehicleSirensOn(source) and 1 or 0 local panel0 = getVehiclePanelState(source, 0) local panel1 = getVehiclePanelState(source, 1) local panel2 = getVehiclePanelState(source, 2) local panel3 = getVehiclePanelState(source, 3) local panel4 = getVehiclePanelState(source, 4) local panel5 = getVehiclePanelState(source, 5) local panel6 = getVehiclePanelState(source, 6) local door0 = getVehicleDoorState(source, 0) local door1 = getVehicleDoorState(source, 1) local door2 = getVehicleDoorState(source, 2) local door3 = getVehicleDoorState(source, 3) local door4 = getVehicleDoorState(source, 4) local door5 = getVehicleDoorState(source, 5) local wheel1, wheel2, wheel3, wheel4 = getVehicleWheelStates(source) local hcol1, hcol2, hcol3 = getVehicleHeadLightColor(source) local panelStates = toJSON( {panel0, panel1, panel2, panel3, panel4, panel5, panel6}) local doorStates = toJSON ( {door0,door1, door2, door3, door4, door5}) local wheelStates = toJSON({wheel1, wheel2, wheel3, wheel4}) local headlights = toJSON({hcol1, hcol2, hcol3}) dbExec(conection,"UPDATE vehicles SET currx=?, curry=?, currz=?, currrx=?, currry=?, currrz=?, engine=?, locked=?, lights=?, sirens=?, paintob=?, hp=?, color1=?, color2=?, color3=?, , color4=? currdimension =?, currinterior=?, panelStates=?, doorStates=?, wheelStates=?,headlights=?, WHERE id=?",tostring(x),tostring(y),tostring(z),tostring(rx),tostring(ry),tostring(rz), tostring(engine), tostring(lights), tostring(locked), tostring(sirens), tostring(paintjob),tostring(hp),tostring(color1), tostring(color2), tostring(color3), tostring(color4), tostring(dimension), tostring(interior), tostring(panelStates), tostring(doorStates), tostring(wheelStates), tostring(headlights), id) end) fromJSOn line 45 expect string at argument 1, got boolen same error at line 46. attempt to index color1 a nil value
-
why restart it addCommandHandler("delpikes", function() for _, object in ipairs(getElementsByType("object")) do if getElementModel(object) == 2892 then destroyElement(object) end end end, false, false)
-
any error or warnign?
-
addCommandHandler("delpikes", function() for _, object in ipairs(getElementsByType("object") do if getElementModel(object) == 2892 then destroyElement(object) end end end, false, false) try this
-
function db_connect() connection = dbConnect("sqlite", ":/global.db") dbExec(connection, "CREATE TABLE IF NOT EXISTS vehicles(id int(11) , model int(3) DEFAULT '0',x decimal(10,6) DEFAULT '0.000000', y demical(10,6) DEFAULT '0.000000' , z demical(10,6) DEFAULT '0.000000', rotx demical(10,6) DEFAULT '0.000000', roty demical(10,6) DEFAULT '0.000000', rotz demical(10,6) DEFAULT '0.000000')") end addEventHandler("onResourceStart", resourceRoot, db_connect) function db_query(callbackFunction, str) return dbQuery(callbackFunction, connection, str) end function db_exec(str) return dbExec(connection, str) end dbQuery expect db-connection argument 1 got nil
-
Errors or warnings
-
no i mean that safecol = createColCuboid ( -746.99713134766, 888.54418945313, 12, 255, 255, 255 ) safeZoneRadar = createRadarArea ( -746.99713134766, 888.54418945313, 150, 150, 153, 235, 255 ) setElementData (safeZoneRadar, "zombieProof", true) function enterZone(hitElement,thePlayer) if isElement(hitElement) and getElementType(hitElement) == "player" then if (getElementData (hitElement, "zombie") == true) then killPed (hitElement) else toggleControl (hitElement, "fire", false ) toggleControl (hitElement, "aim_weapon", false) toggleControl (hitElement, "vehicle_fire", false) end end end addEventHandler( "onColShapeHit", safecol, enterZone ) function leaveZone(leaveElement, thePlayer) if isElement(leaveElement) and getElementType(leaveElement) == "player" then if (getElementData (leaveElement, "zombie") == true) then killPed (leaveElement) else toggleControl (leaveElement, "fire", true) toggleControl (leaveElement, "aim_weapon", true) toggleControl (leaveElement, "vehicle_fire", true) end end end addEventHandler( "onColShapeLeave", safecol, leaveZone )
-
Use That
-
also exist Here
-
local players = getElementsByType("player") for key, value in ipairs(players) do local username = string.lower(tostring(getAccountName(getPlayerAccount(value) ))) if (string.find(username, string.lower(tostring(guiGetText(theEditBox))))) and (guiGetText(theEditBox)~="") then count = count + 1 found = value foundstr = getAccountName(getPlayerAccount(found)) foundid = getElementData(found, "dbid") end end
-
delete this one mistake double post ty
-
---------------------------------------- -- Developer Note: -- THIS RESOURCE CANNOT BE RESTARTED -- WHILE THE SERVER IS RUNNING, IT CAN -- MAKE MINUTES OF NETWORK TROUBLE -- WHILE QUERYING ALL GROUPS DATA ----------------------------------------- local groups = { } addEventHandler ( "onResourceStart", resourceRoot, function ( ) exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS groups ( id INT, name VARCHAR(20), info TEXT )" ); exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS group_members ( id INT, member_name VARCHAR(30), rank VARCHAR(20), join_date VARCHAR(40) )"); exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS group_rank ( id INT, rank VARCHAR(30), perms TEXT )" ) exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS group_logs ( id INT, time VARCHAR(40), account VARCHAR(40), log TEXT )" ) exports.scoreboard:scoreboardAddColumn ( "Group", getRootElement ( ), 90, "Group", 5 ) exports.scoreboard:scoreboardAddColumn ( "Group Rank", getRootElement ( ), 90, "Group Rank", 6 ) for i, v in pairs ( getElementsByType ( "player" ) ) do local g = getElementData ( v, "Group" ) if ( not g ) then setElementData ( v, "Group", "None" ) setElementData ( v, "Group Rank", "None") end if ( not getElementData ( v, "Group Rank" ) ) then setElementData ( v, "Group Rank", "None" ) end end end ) addEventHandler ( "onPlayerJoin", root, function ( ) setElementData ( source, "Group", "None" ) setElementData ( source, "Group Rank", "None") end ) groups = { } --[[ example: groups = { ['ownfexrf__s'] = { info = { founder = "xXMADEXx", -- this CANNOT change founded_time = "2014-06-18:01-35-57", desc = "This is my group", color = { 255, 255, 0 }, type = "Gang", bank = 0, id = 0 }, members = { ["xXMADEXx"] = { rank="Founder", joined="2014-06-18:01-35-57" } }, ranks = { ['Founder'] = { -- member access ['member_kick'] = true, ['member_invite'] = true, ['member_setrank'] = true, ['member_viewlog'] = true -- General group changes ['group_modify_color'] = true,, ['group_modify_motd'] = true, -- banks ['bank_withdraw'] = true, ['bank_deposit'] = true, -- logs ['logs_view'] = true, ['logs_clear'] = true, -- ranks ['ranks_create'] = true, ['ranks_delete'] = true, ['ranks_modify'] = true } }, log = { -- { time, log } { time="2014-06-18 05:05:05", account="xXMADEXx", log="Group Created" } }, pendingInvites = { ['account'] = { inviter = "Inviter Account", time="Time Invite Sent"} } } }]] function saveGroups ( ) exports.NGSQL:db_exec ( "DELETE FROM groups" ) exports.NGSQL:db_exec ( "DELETE FROM group_rank" ) exports.NGSQL:db_exec ( "DELETE FROM group_members") exports.NGSQL:db_exec ( "DELETE FROM group_logs") for i, v in pairs ( groups ) do exports.NGSQL:db_exec ( "INSERT INTO groups ( id, name, info ) VALUES ( ?, ?, ? )", tostring ( v.info.id ), tostring ( i ), toJSON ( v.info ) ) for k, val in pairs ( v.ranks ) do exports.NGSQL:db_exec ( "INSERT INTO group_rank ( id, rank, perms ) VALUES ( ?, ?, ? )", tostring ( v.info.id ), k, toJSON ( val ) ) end for k, val in pairs ( v.members ) do exports.NGSQL:db_exec ( "INSERT INTO group_members ( id, member_name, rank, join_date ) VALUES ( ?, ?, ?, ? )", tostring ( v.info.id ), k, val.rank, val.joined ) end for k, val in ipairs ( v.log ) do exports.NGSQL:db_exec ( "INSERT INTO group_logs ( id, time, account, log ) VALUES ( ?, ?, ?, ? )", tostring ( v.info.id ), val.time, val.account, val.log ) end end end function loadGroups ( ) local start = getTickCount ( ) local groups_ = exports.NGSQL:db_query ( "SELECT * FROM groups" ) for i, v in pairs ( groups_ ) do if ( v and v.name and not groups [ v.name ] ) then groups [ v.name ] = { } groups [ v.name ].info = { } groups [ v.name ].ranks = { } groups [ v.name ].members = { } groups [ v.name ].log = { } -- load info table groups [ v.name ].info = fromJSON ( v.info ) groups [ v.name ].info.id = tonumber ( v.id ) -- load rank table local ranks = exports.NGSQL:db_query ( "SELECT * FROM group_rank WHERE id=?", tostring ( v.id ) ) for i, val in pairs ( ranks ) do if ( not groups [ v.name ].ranks[val.rank] ) then groups [ v.name ].ranks[val.rank] = fromJSON ( val.perms ) end end -- load member table local members = exports.NGSQL:db_query ( "SELECT * FROM group_members WHERE id=?", tostring ( v.id ) ) for i, val in pairs ( members ) do groups [v.name].members[val.member_name] = { } groups [v.name].members[val.member_name].rank = val.rank groups [v.name].members[val.member_name].joined = val.join_date for _, player in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( player ) if ( a and not isGuestAccount ( a ) ) then local acc = getAccountName ( a ) if ( val.member_name == acc ) then setElementData ( player, "Group", tostring ( v.name ) ) setElementData ( player, "Group Rank", tostring ( val.rank ) ) end end end end -- load logs table local log = exports.NGSQL:db_query ( "SELECT * FROM group_logs WHERE id=?", tostring ( v.id ) ) for i, val in ipairs ( log ) do table.insert ( groups[v.name].log, { time=val.time, account=val.account, log=val.log } ) end groups [ v.name ].pendingInvites = { } else local reason = "Variable 'v' not set" if ( v and not v.name ) then reason = "Variable 'v.name' not set" elseif ( v and v.name and groups [ v.name ] ) then reason = "Group already exists in table" else reason = "Undetected" end outputDebugString ( "NGGroups: Failed to load group ".. tostring ( v.name ).." - ".. tostring ( reason ), 1 ) end end local load = math.ceil ( getTickCount()-start ) local tLen = table.len ( groups ) outputDebugString ( "NGGroups: Successfully loaded "..tLen.." groups from the sql database ("..tostring(load).."MS - About "..math.floor(load/tLen).."MS/group)" ) end addEventHandler ( "onResourceStart", resourceRoot, loadGroups ) addEventHandler ( "onResourceStop", resourceRoot, saveGroups ) function getGroups ( ) return groups end addEvent ( "NGGroups->Events:onClientRequestGroupList", true ) addEventHandler ( "NGGroups->Events:onClientRequestGroupList", root, function ( ) local g = getGroups ( ) triggerClientEvent ( source, "NGGroups->onServerSendClientGroupList", source, g ) g = nil end ) ------------------------------ -- Group Creating -- ------------------------------ function createGroup ( name, color, type, owner ) if ( doesGroupExist ( name ) ) then return false end local id = 0 local ids = { } for i, v in pairs ( groups ) do ids [ v.info.id ] = true end while ( ids [ id ] ) do id = id + 1 end groups [ name ] = { info = { founder = owner, -- this CANNOT change founded_time = getThisTime ( ), desc = "", color = color, type = type, bank = 0, id = id }, members = { [owner] = { rank="Founder", joined=getThisTime ( ) } }, ranks = { ['Founder'] = { -- member access ['member_kick'] = true, ['member_invite'] = true, ['member_setrank'] = true, ['member_viewlog'] = true, -- General group changes ['group_modify_color'] = true, ['group_modify_motd'] = true, -- banks ['bank_withdraw'] = true, ['bank_deposit'] = true, -- logs ['logs_view'] = true, ['logs_clear'] = true, -- ranks ['ranks_create'] = true, ['ranks_delete'] = true, ['ranks_modify'] = true }, ["Member"] = { -- button access ['view_member_list'] = true, ['view_ranks'] = false, ['view_bank'] = true, -- member access ['member_kick'] = false, ['member_invite'] = false, ['member_setrank'] = false, -- General group changes ['group_modify_color'] = false, ['group_modify_motd'] = false, -- banks ['bank_withdraw'] = false, ['bank_deposit'] = true, -- logs ['logs_view'] = false, ['logs_clear'] = false, -- ranks ['ranks_create'] = false, ['ranks_delete'] = false, ['ranks_modify'] = false } }, log = { -- { time, log } { time=getThisTime ( ), account="Server", log="Group Created" } }, pendingInvites = { } } return true, groups [ name ] end ------------------------------ -- Group Deleting -- ------------------------------ function deleteGroup ( group ) if ( not doesGroupExist ( group ) ) then return false end local id = groups [ group ].info.id groups [ group ] = nil exports.NGSQL:db_exec ( "DELETE FROM groups WHERE id=?", tostring ( id ) ) exports.NGSQL:db_exec ( "DELETE FROM group_logs WHERE id=?", tostring ( id ) ) exports.NGSQL:db_exec ( "DELETE FROM group_members WHERE id=?", tostring ( id ) ) exports.NGSQL:db_exec ( "DELETE FROM group_rank WHERE id=?", tostring ( id ) ) exports.NGLogs:outputServerLog ( "Group "..tostring ( group ).." deleted" ) for i, v in pairs ( getElementsByType ( "player" ) ) do local gang = getElementData ( v, "Group" ) if ( gang == group ) then setElementData ( v, "Group", "None" ) setElementData ( v, "Group Rank", "None" ) end end exports.NGSQL:db_exec ( "UPDATE accountdata SET GroupName=?, GroupRank=? WHERE GroupName=?", "None", "None", tostring ( group ) ) end addEvent ( "NGGroups->Modules->Gangs->Force->DeleteGroup", true ) addEventHandler ( "NGGroups->Modules->Gangs->Force->DeleteGroup", root, deleteGroup ) addEvent ( "NGGroups->GEvents:onPlayerAttemptGroupMake", true ) addEventHandler ( "NGGroups->GEvents:onPlayerAttemptGroupMake", root, function ( data ) --[[ data = { name = "Group Name", type = "Group Type", color = { r = GroupColorR, g = GroupColorG, b = GroupColorB } } ]] if ( doesGroupExist ( data.name ) or tostring ( data.name ):lower() == "none" ) then return exports.ngmessages:sendClientMessage ( "A group with this name already exists", source, 255, 255, 0 ) end local created, __ = createGroup ( data.name, data.color, data.type, getAccountName ( getPlayerAccount ( source ) ) ) if ( created ) then setElementData ( source, "Group", data.name ); setElementData ( source, "Group Rank", "Founder" ); outputDebugString ( "CREATED GROUP "..tostring(data.name)..". Owner: "..getPlayerName(source) ); refreshPlayerGroupPanel ( source ) return true else outputDebugString ( "FAILED TO CREATE GROUP "..tostring(data.name).." FROM "..getplayerName(source) ); end return false end ) addEvent ( "NGGroups->gEvents:onPlayerDeleteGroup", true ) addEventHandler ( "NGGroups->gEvents:onPlayerDeleteGroup", root, function ( group ) deleteGroup ( group ) exports.NGLogs:outputActionLog ( getPlayerName(source).." ("..getAccountName(getPlayerAccount(source))..") deleted the group: "..tostring(group).." | id: "..tostring ( id ) ) refreshPlayerGroupPanel ( source ) end ) ------------------------------ -- Group Banking Functions -- ------------------------------ function getGroupBank ( group ) if ( groups [ group ] and groups [ group ].info ) then local a = groups [ group ].info.bank or 0 return a end return false end function setGroupBank ( group, money ) if ( groups [ group ] and groups [ group ].info ) then groups [ group ].info.bank = money local a = true return a end return false end function depositGroupBank(group, money) if (not groups[group]) then return end local balance = getGroupBank(group) or 0; setGroupBank(group, balance + money); return true; end addEvent ( "NGGroups:Module->Bank:returnBankBalanceToClient", true ) addEventHandler ( "NGGroups:Module->Bank:returnBankBalanceToClient", root, function ( group ) local bank = getGroupBank ( group ) or 0 triggerClientEvent ( source, "NGGroups:Module->Bank:onServerSendClientBankLevel", source, bank ) end ) addEvent ( "NGGroups:Modules->BankSys:onPlayerAttemptWithdawl", true ) addEventHandler ( "NGGroups:Modules->BankSys:onPlayerAttemptWithdawl", root, function ( group, amount ) if ( not doesGroupExist ( group ) ) then exports.ngmessages:sendClientMessage ( "Something went wrong with the server (Error Code: ngroup-1)", source, 255, 0, 0 ); setElementData ( source, "Group", "None" ); setElementData ( source, "Group Rank", "None" ); refreshPlayerGroupPanel ( source ); return false end local bank = getGroupBank ( group ); if ( amount > bank ) then return exports.ngmessages:sendClientMessage ( "Your group doesn't have $"..tostring(amount).." in their bank account", source, 255, 0, 0 ) end exports.ngmessages:sendClientMessage ( "You have withdrawn $"..tostring(amount).." from your groups bank... Actions logged", source, 0, 255, 0 ) givePlayerMoney ( source, amount ) setGroupBank ( group, bank - amount ) outputGroupLog ( group, "Withdrew $"..tostring(amount).." from the group bank", source ) end ) addEvent ( "NGGroups:Modules->BankSys:onPlayerAttemptDeposit", true ) addEventHandler ( "NGGroups:Modules->BankSys:onPlayerAttemptDeposit", root, function ( group, amount ) if ( not doesGroupExist ( group ) ) then exports.ngmessages:sendClientMessage ( "Something went wrong with the server (Error Code: ngroup-2)", source, 255, 0, 0 ); setElementData ( source, "Group", "None" ); setElementData ( source, "Group Rank", "None" ); refreshPlayerGroupPanel ( source ); return false end local m = source.money; if ( amount > m ) then return exports.ngmessages:sendClientMessage ( "You don't have $"..tostring(amount), source, 255, 0, 0 ) end exports.ngmessages:sendClientMessage ( "You deposited $"..tostring(amount).." into your group bank", source, 0, 255, 0 ) source.money = m - amount; outputGroupLog ( group, "Deposited $"..tostring(amount).." into the group bank", source ) setGroupBank ( group, getGroupBank ( group ) + amount ) end ) ------------------------------ -- Group Member Functions -- ------------------------------ function getPlayerGroup ( player ) local g = getElementData ( player, "Group" ) or "None" if ( g:lower ( ) == "none" ) then g = nil end return g end function refreshPlayerGroupPanel ( player ) triggerClientEvent ( player, "NGGroups->pEvents:onPlayerRefreshPanel", player ) player = nil end function setPlayerGroup ( player, group ) local acc = getPlayerAccount ( player ) if ( isGuestAccount ( acc ) ) then return false end if ( not group ) then group = "None" end if ( group ~= "None" ) then if ( not groups [ group ] ) then return false end end setElementData ( player, "Group", group ) if ( group == "None" ) then return setElementData ( player, "Group Rank", "None" ) else groups [ group ].members [ getAccountName ( acc ) ] = { rank="Member", joined=getThisTime() } return setElementData ( player, "Group Rank", "Member" ) end return false end addEvent ( "NGGroups->Modules->Gangs->kickPlayer", true ) addEventHandler ( "NGGroups->Modules->Gangs->kickPlayer", root, function ( group, account ) exports.ngsql:db_exec ( "UPDATE accountdata SET GroupName=?, GroupRank=? WHERE Username=?", "None", "None", account ) for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( not isGuestAccount ( a ) and getAccountName ( a ) == account ) then setElementData ( v, "Group", "None" ) setElementData ( v, "Group Rank", "None" ) outputChatBox ( "You got kicked from your group.", v, 255, 0, 0) break end end groups [ group ].members [ account ] = nil exports.ngmessages:sendClientMessage ( "You kicked "..tostring(account).." from "..tostring(group), source, 255, 255, 0 ) outputGroupLog ( group, "Kicked account "..tostring(account), source ) refreshPlayerGroupPanel ( source ) end ) addEvent ( "NGGroups->Modules->Groups->OnPlayerLeave", true ) addEventHandler ( "NGGroups->Modules->Groups->OnPlayerLeave", root, function ( g ) groups[g].members[getAccountName(getPlayerAccount(source))] = nil setPlayerGroup ( source, nil ) refreshPlayerGroupPanel ( source ) outputGroupLog ( g, "Has left the group", source ) end ) ------------------------------------------ -- Players -> Group Ranking Functions -- ------------------------------------------ function setAccountRank ( group, account, newrank ) local account, newrank = tostring ( account ), tostring ( newrank ) exports.ngsql:db_exec ( "UPDATE accountdata SET GroupRank=? WHERE Username=?", newrank, account ) groups[group].members[account].rank = newrank for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( a and not isGuestAccount ( a ) and a == account ) then setElementData ( v, "Group Rank", tostring ( newrank ) ) outputChatBox ( "You rank has been changed to "..tostring ( newrank ), v, 255, 255, 0) break end end return true end addEvent ( "NGGroups->Modules->Gangs->Ranks->UpdatePlayerrank", true ) addEventHandler ( "NGGroups->Modules->Gangs->Ranks->UpdatePlayerrank", root, function ( group, account, newrank ) if ( not groups[group] or not groups[group].ranks[newrank] ) then exports.ngmessages:sendClientMessage ( "Oops, something went wrong. Please try again", source, 255, 0, 0 ) refreshPlayerGroupPanel ( source ) return false end outputGroupLog ( group, "Changed "..account.."'s rank from "..groups[group].members[account].rank.." to "..newrank, source ) setAccountRank ( group, account, newrank ) exports.ngmessages:sendClientMessage ( "You have changed "..tostring ( account ).."'s rank!", source, 255, 255, 0) refreshPlayerGroupPanel ( source ) end ) function sendPlayerInvite ( player, group, inviter ) local a = getPlayerAccount ( player ) if ( isGuestAccount( a ) ) then return false end local a = getAccountName ( a ) if ( groups [ group ].pendingInvites [ a ] ) then return false end table.insert ( groups [ group ].pendingInvites, { to=getAccountName(getPlayerAccount(player)), inviter=getAccountName(getPlayerAccount(inviter)), time=getThisTime() } ); return true end addEvent ( "NGGroups->Modules->Groups->InvitePlayer", true ) addEventHandler ( "NGGroups->Modules->Groups->InvitePlayer", root, function ( group, plr ) local a = getPlayerAccount ( plr ) if ( isGuestAccount ( a ) ) then return exports.ngmessages:sendClientMessage ( "Your group request couldn't be sent to "..plr.name, source, 255, 0, 0 ) end local a = getAccountName ( a ) for _, info in pairs ( groups [ group ].pendingInvites ) do if ( info.to == a ) then return exports.ngmessages:sendClientMessage ( "This player is already invited by "..tostring(info.from), source, 255, 255, 0 ) end end outputGroupLog ( group, "Invited "..plr.name.." ("..a..")", source ) local r, g, b = getGroupColor ( group ); exports.ngmessages:sendClientMessage ( source.name.." invited you to "..group..". Accept it in F3", plr, r, g, b ) exports.ngmessages:sendClientMessage ( "You have invited "..plr.name.." to the group", source, r, g, b ) sendPlayerInvite ( plr, group, source ) end ) addEvent ( "NGGroups->Modules->Groups->Invites->OnPlayerDeny", true ) addEventHandler( "NGGroups->Modules->Groups->Invites->OnPlayerDeny", root, function ( g ) local a = getAccountName ( getPlayerAccount ( source ) ) groups [ g ].pendingInvites [ a ] = nil refreshPlayerGroupPanel ( source ) end ) addEvent ( "NGGroups->Modules->Groups->Invites->OnPlayerAccept", true ) addEventHandler ( "NGGroups->Modules->Groups->Invites->OnPlayerAccept", root, function ( g ) local a = getAccountName ( getPlayerAccount ( source ) ) for index, info in pairs ( groups [ g ].pendingInvites ) do if ( info.to == a ) then table.remove ( groups [ g ].pendingInvites, index ) end end groups [ g ].members [ a ] = { rank="Member", joined = getThisTime() } setPlayerGroup ( source, g ) outputGroupMessage ( getPlayerName ( source ).." has joined the group!", g ) refreshPlayerGroupPanel ( source ) end ) function addRankToGroup ( group, name, info ) if ( not groups [ group ] ) then return false end for i, v in pairs ( groups [ group ].ranks ) do if ( i:lower() == name:lower() ) then return false end end groups [ group ].ranks [ name ] = info return true end addEvent ( "NGGroups->Modules->Groups->Ranks->AddRank", true ) addEventHandler ( "NGGroups->Modules->Groups->Ranks->AddRank", root, function ( group, name, info ) outputGroupLog ( group, "Added rank '"..tostring(name).."'", source ) addRankToGroup ( group, name, info ) refreshPlayerGroupPanel ( source ) exports.ngmessages:sendClientMessage ( "The rank has been added.", source, 0, 255, 0 ) end ) function setGroupMotd ( group, motd ) if ( groups [ group ] ) then groups[group].info.desc = tostring ( motd ) return true end return false end addEvent ( "NGGroups->Modules->Groups->MOTD->Update", true ) addEventHandler ( "NGGroups->Modules->Groups->MOTD->Update", root, function ( g, mo ) outputGroupLog ( g, "Changed the group MOTD", source ) setGroupMotd ( g, mo ) refreshPlayerGroupPanel ( source ) end ) ------------------------------ -- Group Checking Functions -- ------------------------------ function doesGroupExist ( group ) local group = tostring ( group ):lower ( ) for i, v in pairs ( groups ) do if ( tostring ( i ):lower ( ) == group ) then group = nil return true end end group = nil return false end function isRankInGroup ( group, rank ) local group = tostring ( group ):lower ( ) for i, v in pairs ( groups ) do if ( i:lower() == group ) then if ( v.ranks and v.ranks [ rank ] ) then return true end break end end return false end ------------------------------ -- Group Logging -- ------------------------------ function groupClearLog ( group ) if ( groups [ group ] ) then groups [ group ].log = nil exports.NGSQL:db_exec ( "DELETE FROM group_logs WHERE id=?", groups[group].info.id ) groups [ group ].log = { } group = nil return true end group = nil return false end function outputGroupLog ( group, log, element ) if ( not groups[group] ) then return end if ( not groups[group].log ) then groups[group].log = { } end local e = "Server" if ( element ) then e = element if ( type ( element ) == "userdata" ) then if ( getElementType ( element ) == "player" ) then local a = getPlayerAccount ( element ) if ( not isGuestAccount ( a ) ) then e = getAccountName ( a ) end a = nil end end end table.insert ( groups[group].log, 1, { time=getThisTime(), account=e, log=log } ) end function getGroupLog ( group ) if ( group and groups [ group ] ) then local f = groups [ group ].log return f end end addEvent ( "NGGroups->GEvents:onPlayerClearGroupLog", true ) addEventHandler ( "NGGroups->GEvents:onPlayerClearGroupLog", root, function ( group ) groupClearLog ( group ) outputGroupLog ( group, "Cleared the logs", source ) refreshPlayerGroupPanel ( source ) -- memory sweep group = nil end ) addEvent( "NGGroups->GroupStaff:OnAdminDeleteGroup", true ); addEventHandler ( "NGGroups->GroupStaff:OnAdminDeleteGroup", root, function ( group ) exports.nglogs:outputActionLog ( "Staff "..source.name.." ("..source.account.name..") delete the '"..group.."' group" ); for _, p in pairs ( getElementsByType ( "player" ) ) do if ( tostring ( getElementData ( p, "Group" ) ) == group ) then outputChatBox ( "Admin "..tostring(source.name).." has deleted your group.", p, 255, 0, 0 ); end end deleteGroup ( group ); refreshPlayerGroupPanel ( source ); end ); ------------------------------ -- Misc Functions -- ------------------------------ function getThisTime ( ) local time = getRealTime ( ) local year = time.year + 1900 local month = time.month + 1 local day = time.monthday local hour = time.hour local min = time.minute local sec = time.second if ( month < 10 ) then month = 0 .. month end if ( day < 10 ) then day = 0 .. day end if ( hour < 10 ) then hour = 0 .. hour end if ( min < 10 ) then min = 0 .. min end if ( sec < 10 ) then sec = 0 .. sec end return table.concat ( { year, month, day }, "-") .. " "..table.concat ( { hour, min, sec }, ":" ) end function getGroupColor ( group ) local r, g, b = 0, 0, 0 if ( groups [ group ] ) then r, g, b = groups[group].info.color.r, groups[group].info.color.g, groups[group].info.color.b end return r, g, b end function setGroupColor ( group, r, g, b ) if ( groups [ group ] ) then groups[group].info.color.r = r groups[group].info.color.g = g groups[group].info.color.b = b exports.ngturf:updateTurfGroupColor ( group ) return true end return false end addEvent("NGGroups->Modules->Groups->Colors->UpdateColor",true) addEventHandler("NGGroups->Modules->Groups->Colors->UpdateColor",root,function(group,r,g,b) outputGroupLog ( group, "Changed group color to ".. table.concat ( { r, g, b }, ", " ), source ) setGroupColor ( group, r, g, b ) refreshPlayerGroupPanel ( source ) end ) function getGroupType ( name ) if ( doesGroupExist ( name ) ) then return groups [ name ].info.type; end return false; end function isRankInGroup ( group, rank ) if ( doesGroupExist ( group ) ) then if ( groups [ group ].ranks [ rank ] ) then return true end end return false end function outputGroupMessage ( message, group, blockTag ) local blockTag = blockTag or false if ( not blockTag ) then message = "("..tostring(group)..") "..tostring(message) end local r, g, b = getGroupColor ( group ) local group = tostring ( group ):lower ( ) for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( tostring ( getElementData ( v, "Group" ) ):lower ( ) == group:lower() ) then outputChatBox ( message, v, r, g, b, true ) end end end function table.len ( t ) local c = 0 for i in pairs ( t ) do c = c + 1 end return c end -- group chat -- addCommandHandler ( "clanc", function ( plr, _, ... ) local message = table.concat ( { ... }, " " ) local g = getPlayerGroup ( plr ) if ( not g ) then return exports.ngmessages:sendClientMessage ( "You cannot use this command, you're not in a group", plr, 255, 0, 0 ) end if ( message:gsub ( " ", "" ) == "" ) then return exports.ngmessages:sendClientMessage ( "You didn't enter a message. Syntax: /clanc message", plr, 255, 0, 0 ) end outputGroupMessage("Group| ".. exports.ngchat:getChatLine ( plr, message ), g, true ) end ) When i set someone rank it good on gui but in scoreboard not change why?