-
Posts
1,546 -
Joined
-
Last visited
Everything posted by Dimos7
-
local marker = createMarker(arguments) function markerHit ( hitElement ) if getElementType (hitElement) == "player" then local starter = getPlayerName (hitElement) outputChatBox(starter.." has started the resource!", root, 255, 0, 0, true) destroyElement (marker) startResource (arguments) setTimer( function() marker = createMarker(arguments) stopResource(arguments) outputChatBox("Resource stopped", root, 255, 0, 0) end, 600000,1) end end addEventHandler("onMarkerHit", marker, markerHit)
-
try something about your self and if you have error we help you
-
function adminDuty(thePlayer, commandName) if exports.global:isPlayerAdmin(thePlayer) then local id = getElementData(thePlayer, "playerid") local adminduty = getElementData(thePlayer, "adminduty") local username = getPlayerName(thePlayer) local adminnev = getElementData(thePlayer, "gameaccountusername") local karinev = mysql:query("SELECT * FROM characters WHERE charactername=?", charactername) if (adminduty==0) then exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) setPlayerName (thePlayer, adminnev) outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(), 255, 255, 255, true) elseif (adminduty==1) then local adminlevel = getElementData(thePlayer, "adminlevel") if (adminlevel == 2) then outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) return end exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) setPlayerName (thePlayer, karinev) outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) end mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) exports.global:updateNametagColor(thePlayer) end end addCommandHandler("adminduty", adminDuty, false, false)
-
take wepon is server side not clinet btw
-
function adminDuty(thePlayer, commandName) if exports.global:isPlayerAdmin(thePlayer) then local id = getElementData(thePlayer, "playerid") local adminduty = getElementData(thePlayer, "adminduty") local username = getPlayerName(thePlayer) local adminnev = getElementData(thePlayer, "gameaccountusername") local karinev = mysql:query("SELECT * FROM characters WHERE charactername=?") if (adminduty==0) then exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) setPlayerName (thePlayer, adminnev) outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(), 255, 255, 255, true) elseif (adminduty==1) then local adminlevel = getElementData(thePlayer, "adminlevel") if (adminlevel == 2) then outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) return end exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) setPlayerName (thePlayer, karinev) outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) end mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) exports.global:updateNametagColor(thePlayer) end end addCommandHandler("adminduty", adminDuty, false, false)
-
nvm not had put correct the module name
-
Yes i do --connection Settings local hostname = "127.0.0.1" local username = "root" local password = "" local database ="inrpg" local port = 3306 -- global things local MySQLConnection = nil local resultPool = { } local sqllog = false local countqueries = 0 -- connectToDatabse - Internal function, to spawn a DB connection function connectToDatabse(res) MySQLConnection = mysql_connect(hostname, username, password, database, port) if (not MySQLConnection) then if (res == getThisResource()) then cancelEvent(true, "Cannot connect to the database") end return nil end end addEventHandler("onResourceStart", resourceRoot, connectToDatabse) -- destroyDatabaseConnection - Internal function, to kill the connection if theres one function destroyDatabaseConnection() if (not MySQLConnection) then return nil end mysql_close(MySQLConnection) return nil end addEventHandler("onResourceStop", resourceRoot, destroyDatabaseConnection) -- do something useful here function logSQLError(str) local message = str or "N/A" outputDebugString("MYSQL ERROR"..mysql_errno(MySQLConnection)..": "..mysql_error(MySQLConnection)) exports.logs:logMessage("MYSQL ERROR ! [QUERY]"..message.." [ERROR] "..mysql_errno(MySQLConnection)..": "..mysql_error(MySQLConnection), 18) end function getFreeRsultPoolID() local size = #resultPool if (size == 0) then return 1 end for index, query in ipairs(resultPool) do if (query ==nil) then return index end end return (size + 1) end ---------- EXPORTED FUNCTIONS ---------- function ping() if (mysql_ping(MySQLConnection) == false) then destroyDatabaseConnection() connectToDatabse(nil) if (mysql_ping(MySQLConnection) == false) then logSQLError() return false end return true end end function escape_string(str) if (ping()) then return mysql_escape_string(MySQLConnection, str) end return false end function query(str) if sqllog then exports.logs:logMessage(str, 18) end countqueries = countqueries + 1 if (ping()) then local result = mysql_query(MySQLConnection, str) if (not result) then logSQLError(str) return false end local resultid = getFreeRsultPoolID() resultPool[resultid] = result return resultid end return false end function unbuffered_qyery(str) if sqllog then exports.logs:logMessage(str, 18) end countqueries = countqueries + 1 if (ping()) then local result = mysql_unbuffered_query(MySQLConnection, str) if (not result) then logSQLError(str) return false end local resultid = getFreeRsultPoolID() resultPool[resultid] = result return resultid end return false end function query_free(str) local queryresult = query(str) if not (queryresult == false) then free_result(queryresult) return true end return false end function rows_assoc(resultid) if (not resultPool[resultid]) then return false end return mysql_rows_assoc(resultPool[resultid]) end function fetch_assoc(resultid) if (not resultPool[resultid])then return false end return mysql_fetch_assoc(resultPool[resultid]) end function free_result(resultid) if (not resultPool[resultid]) then return false end mysql_free_result(resultPool[resultid]) table.remove(resultPool, resultid) return nil end -- incase a nub wants to use it,FINE function result(resultid, row_offset, field_offset) if (not resultPool[resultid]) then return false end return mysql_result(resultPool[resultid]) end function num_rows(resultid) if (not resultPool[resultid]) then return false end return mysql_num_rows(resultPool[resultid]) end function insert_id() return mysql_insert_id(MySQLConnection) or false end function query_fetch_assoc(str) local queryresult = query(str) if not (queryresult == false) then local result = fetch_assoc(queryresult) free_result(queryresult) return result end return false end function query_rows_assoc(str) local queryresult = query(str) if not (queryresult == false) then local result = rows_assoc(queryresult) free_result(queryresult) return result end return false end function query_insert_free(str) local queryresult = query(str) if not (queryresult == false) then local result = insert_id() free_result(queryresult) return result end return false end function escape_string(str) return mysql_escape_string(MySQLConnection, str) end function debugMode() if (sqllog) then sqllog = false else sqllog = true end return sqllog end function returnQueryStats() return countqueries end ERROR: mysql\connection.lua:16: attempt to call global 'mysql_connect' (a nil value)
-
--connection Settings local hostname = "127.0.0.1" local username = "root" local password = "" local database ="inrpg" local port = 3306 -- global things local MySQLConnection = nil local resultPool = { } local sqllog = false local countqueries = 0 -- connectToDatabse - Internal function, to spawn a DB connection function connectToDatabse(res) MySQLConnection = mysql_connect(hostname, username, password, database, port) if (not MySQLConnection) then if (res == getThisResource()) then cancelEvent(true, "Cannot connect to the database") end return nil end end addEventHandler("onResourceStart", resourceRoot, connectToDatabse) -- destroyDatabaseConnection - Internal function, to kill the connection if theres one function destroyDatabaseConnection() if (not MySQLConnection) then return nil end mysql_close(MySQLConnection) return nil end addEventHandler("onResourceStop", resourceRoot, destroyDatabaseConnection) -- do something useful here function logSQLError(str) local message = str or "N/A" outputDebugString("MYSQL ERROR"..mysql_errno(MySQLConnection)..": "..mysql_error(MySQLConnection)) exports.logs:logMessage("MYSQL ERROR ! [QUERY]"..message.." [ERROR] "..mysql_errno(MySQLConnection)..": "..mysql_error(MySQLConnection), 19) end function getFreeRsultPoolID() local size = #resultPool if (size == 0) then return 1 end for index, query in ipairs(resultPool) do if (query ==nil) then return index end end return (size + 1) end ---------- EXPORTED FUNCTIONS ---------- function ping() if (mysql_ping(MySQLConnection) == false) then destroyDatabaseConnection() connectToDatabse(nil) if (mysql_ping(MySQLConnection) == false) then logSQLError() return false end return true end end function escape_string(str) if (ping()) then return mysql_escape_string(MySQLConnection, str) end return false end function query(str) if sqllog then exports.logs:logMessage(str, 19) end countqueries = countqueries + 1 if (ping()) then local result = mysql_query(MySQLConnection, str) if (not result) then logSQLError(str) return false end local resultid = getFreeRsultPoolID() resultPool[resultid] = result return resultid end return false end function unbuffered_qyery(str) if sqllog then exports.logs:logMessage(str, 19) end countqueries = countqueries + 1 if (ping()) then local result = mysql_unbuffered_query(MySQLConnection, str) if (not result) then logSQLError(str) return false end local resultid = getFreeRsultPoolID() resultPool[resultid] = result return resultid end return false end function query_free(str) local queryresult = query(str) if not (queryresult == false) then free_result(queryresult) return true end return false end function rows_assoc(resultid) if (not resultPool[resultid]) then return false end return mysql_rows_assoc(resultPool[resultid]) end function fetch_assoc(resultid) if (not resultPool[resultid])then return false end return mysql_fetch_assoc(resultPool[resultid]) end function free_result(resultid) if (not resultPool[resultid]) then return false end return mysql_free_result(resultPool[resultid]) table.remove(resultPool, resultid) return nil end -- incase a nub wants to use it,FINE function result(resultid, row_offset, field_offset) if (not resultPool[resultid]) then return false end return mysql_result(resultPool[resultid]) end function num_rows(resultid) if (not resultPool[resultid]) then return false end return mysql_num_rows(resultPool[resultid]) end function insert_id() return mysql_insert_id(MySQLConnection) or false end function query_fetch_assoc(str) local queryresult = query(str) if not (queryresult == false) then local result = fetch_assoc(queryresult) free_result(queryresult) return result end return false end function query_rows_assoc(str) local queryresult = query(str) if not (queryresult == false) then local result = rows_assoc(queryresult) free_result(queryresult) return result end return false end function query_insert_free(str) local queryresult = query(str) if not (queryresult == false) then local result = insert_id() free_result(queryresult) return result end return false end function escape_string(str) return mysql_escape_string(MySQLConnection, str) end function debugMode() if (sqllog) then sqllog = false else sqllog = true end return sqllog end function returnQueryStats() return countqueries end ERROR: Loading script failed: mysql\connection.lua:146: 'end' expected (to close 'function' at line 141) near 'table'
-
Client local GUIEditor = { window = {}, label = {}, button = {}, edit = {} } function createPasswordWindow() GUIEditor.window[1]= guiCreateWindow(714, 272, 502, 344, "Password change:", false) GUIEditor.label[1]= guiCreateLabel(10, 38, 75, 15, "Password:", false, GUIEditor.window[1]) GUIEditor.edit[1]= guiCreateEdit(85, 34, 359, 37, "", false, GUIEditor.window[1]) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2]= guiCreateLabel(10, 115, 75, 15, "Repeat:", false, GUIEditor.window[1]) GUIEditor.edit[2]= guiCreateEdit(85, 101, 359, 37, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1]= guiCreateButton(92, 241, 126, 84, "Change", false, GUIEditor.window[1]) GUIEditor.button[2]= guiCreateButton(235, 241 ,126, 84, "Cancel", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw) addEventHandler("onClientGUIClick", GUIEditor.button[2], clientCancelChangepw) end function createLoginWindow() GUIEditor.window[2]= guiCreateWindow(714, 272, 502, 344, "Infernus panel", false) GUIEditor.label[3]= guiCreateLabel(10, 38, 75, 15, "Username:", false, GUIEditor.window[2]) GUIEditor.edit[3]= guiCreateEdit(85, 34, 359, 37, "", false, GUIEditor.window[2]) GUIEditor.label[4]= guiCreateLabel(10, 115, 75, 15, "Password:", false, GUIEditor.window[2]) GUIEditor.edit[4]= guiCreateEdit(85, 101, 359, 37, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.button[3]= guiCreateButton(92, 241, 126, 84, "Login", false, GUIEditor.window[2]) GUIEditor.button[4]= guiCreateButton(235, 241, 126, 84, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister) end function resourceStart () createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occurred!") end showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", resourceRoot, resourceStart) function changePw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientCancelChangepw(button, state) if button == "left" and state ==" down" then if source == GUIEditor.button[2] then guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "down" then if source == GUIEditor.button[1] then password = guiGetText(GUIEditor.edit[1]) cpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and cpassword ~="" then triggerServerEvent("submitChangepw", root, localPlayer, password, cpassword) else outputChatBox("You need put password and confirmpassword!") end end end end function clientSubmitLogin(button, state) if button == "left" and state == "down" then if source == GUIEditor.button[3] then username = guiGetText(GUIEditor.edit[3]) password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitLogin", root, localPlayer, username, password) else outputChatBox("You need put username and password!") end end end end function clientSubmitRegister(button, state) if button == "left" and state == "down" then if source == GUIEditor.button[4] then username = guiGetText(GUIEditor.edit[3]) password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitRegister", root, localPlayer, username, password) else outputChatBox("You need put username and password!") end end end end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hidePasswordWindow", true) addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addCommandHandler("changepass", changePw) Server local connection = exports.SQL:getSQLConnection() function passwordHandler(thePlayer, password, cpassword) local account = getPlayerAccount(thePlayer) if (account) then if (isGuestAccount(account)) then outputChatBox("You must be logged in to change your password!", thePlayer, 255, 0, 0) return end if password == cpassword then if (string.len(password)>= 5) then setAccountPassword(account, password) triggerClientEvent(thePlayer, "hidePaswwordWindow", root) dbExec(connection, "UPATE accounts SET password=?", tostring(password)) else outputChatBox("Your new password must be at least 5 characters long!", thePlayer, 255, 0, 0) end else outputChatBox("Password aren't the same!", thePlayer, 255, 0, 0) end end end function loginHandler(thePlayer, username, password) local account = getAccount(username, password) local query = dbQuery(connection, "SELECT * FROM accounts WHERE username=? and password=?", username, password) local result, num_affected_row = dbPoll(query, -1) if (account ~= false) and num_affected_row == 1 then if (logIn(thePlayer, account, password) == true) then outputChatBox("Welcome back to Infernus RPG!", thePlayer, 0, 255, 150) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("Account not found!", thePlayer, 255, 0, 0) end else outputChatBox("Username or password are invaild!", thePlayer, 255, 0, 0) end end function registerHandler(thePlayer, username, password) local account = getAccount(username, password) local query = dbQuery(connection, "SELECT * FROM accounts WHERE username=? and password=?", username, password) local result, num_affected_row = dbPoll(query, -1) if (account ~= false) and num_affected_row == 1 then outputChatBox("This username alread exist!", thePlayer, 255, 0, 0) else account = addAccount(username, password) outputChatBox("You succefully register!", thePlayer, 0, 255, 0) dbExec(connection, "INSERT INTO accounts(username, password, name, serial) VALUES ('"..tostring(username)..'","'..tostring(password).."','"..tostring(getPlayerName(thePlayer))..'","'..tostring(getPlayerSerial(thePlayer)).."')") if (logIn(thePlayer, account, password) == true ) then outputChatBox("Welcome to Infernus RPG", thePlayer, 0, 255, 150) triggerClientEvent(thePlayer, "hideLoginWindow", root) else outputChatBox("Account not found!", thePlayer, 255, 0, 0) end end end addEvent("submitChangepw", true) addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitChangepw", root, passwordHandler) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) Not error or warning when click login orRegister nothing happend and yes its on admin group
-
local GUIEditor = { window, label, button, edit } function createPasswordWindow() GUIEditor.window[1]= guiCreateWindow(714, 272, 502, 344, "Password change:", false) GUIEditor.label[1]= guiCreateLabel(10, 38, 75, 15, "Password:", false, GUIEditor.window[1]) GUIEditor.edit[1]= guiCreateEdit(85, 34, 359, 37, "", false, GUIEditor.window[1]) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[2]= guiCreateLabel(10, 115, 75, 15, "Repeat:", false, GUIEditor.window[1]) GUIEditor.edit[2]= guiCreateEdit(85, 101, 359, 37, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1]= guiCreateButton(92, 241, 126, 84, "Change", false, GUIEditor.window[1]) GUIEditor.button[2]= guiCreateButton(235, 241 ,126, 84, "Cancel", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) addEventHandler("onClientGUIClick", GUIEditor.button[1], clientSubmitChangepw) addEventHandler("onClientGUIClick", GUIEditor.button[2], clientCancelChangepw) end function createLoginWindow() GUIEditor.window[2]= guiCreateWindow(714, 272, 502, 344, "Infernus panel", false) GUIEditor.label[3]= guiCreateLabel(10, 38, 75, 15, "Username:", false, GUIEditor.window[2]) GUIEditor.edit[3]= guiCreateEdit(85, 34, 359, 37, "", false, GUIEditor.window[2]) GUIEditor.label[4]= guiCreateLabel(10, 115, 75, 15, "Password:", false, GUIEditor.window[2]) GUIEditor.edit[4]= guiCreateEdit(85, 101, 359, 37, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[4], true) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.button[3]= guiCreateButton(92, 241, 126, 84, "Login", false, GUIEditor.window[2]) GUIEditor.button[4]= guiCreateButton(235, 241, 126, 84, "Register", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], clientSubmitLogin) addEventHandler("onClientGUIClick", GUIEditor.button[4], clientSubmitRegister) end function resourceStart () createLoginWindow() if (GUIEditor.window[2] ~= nil) then guiSetVisible(GUIEditor.window[2], true) else outputChatBox("An error has occurred!") end showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", resourceRoot, resourceStart) function changePw() createPasswordWindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) guiSetInputEnabled(true) end function clientCancelChangepw(button, state) if button == "left" and state ==" down" then if source == GUIEditor.button[2] then guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "down" then if source == GUIEditor.button[1] then password = guiGetText(GUIEditor.edit[1]) cpassword = guiGetText(GUIEditor.edit[2]) if password ~= "" and cpassword ~="" then triggerServerEvent("submitChangepw", root, localPlayer, password, cpassword) else outputChatBox("You need put password and confirmpassword!") end end end end function clientSubmitLogin(button, state) if button == "left" and state == "down" then if source == GUIEditor.button[3] then username = guiGetText(GUIEditor.edit[3]) password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitLogin", root, localPlayer, username, password) else outputChatBox("You need put username and password!") end end end end function clientSubmitRegister(button, state) if button == "left" and state == "down" then if source == GUIEditor.button[4] then username = guiGetText(GUIEditor.edit[3]) password = guiGetText(GUIEditor.edit[4]) if username ~= "" and password ~= "" then triggerServerEvent("submitRegister", root, localPlayer, username, password) else outputChatBox("You need put username and password!") end end end end function hidePasswordWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) end function hideLoginWindow() guiSetVisible(GUIEditor.window[2], false) showCursor(false) guiSetInputEnabled(false) end addEvent("hidePasswordWindow", true) addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addCommandHandler("changepass", changePw) line 26 attempt to index field window a nill value
-
I don't think so but i am not sure
-
local images ={ {"", 1} } function startDownloadImage(playerToReceive) for i = 1 , #images do fetchRemote(images, myCallback, "", false, playerdToReceive) end end function myCallback(responseData, errno, playerToReceive) if errno == 0 then triggerClientEvent(playerToReceive, "onClientGotImage", resourceRoot, responseData) end end
-
that is server side not client
-
addEventHandler("onPlayerLogin", root, function() bindKey(source, "n", "down", factionVehicle) end) addEventHandler("onResourceStart", root, function() for p, v in ipairs(getElementsByType("player")) do bindKey(v, "n", "down", factionVehicle) end end) function factionVehicle(thePlayer, theVehicle) --your code end
-
addEventHandler("onPlayerWasted", root, function(attacker, weapon, ammo, bodypart) if (attacker and attacker ~= source and isElement(attacker) and getElementType(attacker) == "player" and bodypart == 9 )then exports["topbarchat"]:sendClientMessage("[server-Dragon] Head shot", attacker, 0, 255, 0) triggerClientEvent(attacker, "text", attacker) end end)
-
addEventHandler("onPlayerWasted", root function(attacker, weapon, ammo, bodypart) if (attacker and attacker ~= source and isElement(attacker) and bodypart == 9) then exports["topbarchat"]:sendClientMessage("[server-Dragon] Head Shot", attacker, 0, 255, 0) triggerClientEvent(attacker , "text", attacker) end end)
-
-- onDestroyVehicle ---------------------------------------------------------------------------------------- addEventHandler("onVehicleExit", root, function() if not isVehicleCreatedByPlayer(source) or not isVehicleEmpty(source) then return --It's not a vehicle created by a player or the vehicle is not empty then cancel end local destroyTimer = setTimer( function(vehicle) if isElement(vehicle) then destroyElement(vehicle) end end, 5000, 1, source) setElementData(source, "destroyTimer", destroyTimer) end) addEventHandler("onVehicleEnter", root, function() if not isVehicleCreatedByPlayer(source) then return end local destroyTimer = getElementData(source, "destroyTimer") if isTimer(destroyTimer) then killTimer(destroyTimer) removeElementData(source, "destroyTimer") end end) function getVehicleCreatedByPlayer(player) for p,v in (veiculo) do if p == player then return v end end return nil end function getVehicleOwner(vehicle) for p, v in pairs(veiculo) do if v == vehicle then return p end end return nil end function isVehicleCreatedByPlayer(vehicle) local owner = getVehicleOwner(vehicle) return owner and getElementType(owner) =="player" end -- From [url=https://wiki.multitheftauto.com/wiki/isVehicleEmpty]https://wiki.multitheftauto.com/wiki/isVehicleEmpty[/url] function isVehicleEmpty(vehicle) if not isElement(vehicle) or getElementType(vehicle) ~= "vehicle" then return true end local passengers = getVehicleMaxPassengers(vehicle) if type(passengers) == "number" then for seat = 0, passengers do if getVehicleOccupant(vehicle, seat) then return false end end end return true end ----------------------- function destoirCarro() local vehicle = getVehicleCreatedByPlayer(source) if vehicle and isElement(vehicle) then destroyElement(vehicle) end end addEventHandler("onPlayerLogout", root, destoirCarro) addEventHandler("onPlayerQuit", root, destoirCarro) addEventHandler("onPlayerWasted", root, destoirCarro) -- onVehicleExplode function VehicleExplode() if not isVehicleCreatedByPlayer(source) then return end local owner = getVehicleOwner(source) setTimer( function(vehicle, owner) destroyElement(vehicle) veiculo[owner] = nil end, 5000, 1, source, owner) end addEventHandler("onVehicleExplode", root, VehicleExplode)
-
function freeze(thePlayer) local occveh = getPedOccupiedVehicle(thePlayer) if isPedInVehicle(thePlayer) then if isElementFrozen(occveh) == false then outputChatBox("Your vehicle has been frozen!", thePlayer, 79, 226, 249) setElementFrozen(occveh, true) else outputChatBox("Your vehicle has been unfrozen!", thePlayer, 79, 226, 249) setElementFrozen(occveh, false) elseif isElementFrozen(thePlayer) == true then outputChatBox("You have been unfrozen!", thePlayer, 79, 226, 249) setElementFrozen(thePlayer, false) else outputChatBox("You have been frozen!", thePlayer, 79, 226, 249) setElementFrozen(thePlayer, true) end end end addCommandHandler("freeze", freeze)