-
Posts
1,491 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Walid
-
Try this untested i'm using the phone function teleport(thePlayer,cmd,target) local account = getPlayerAccount(thePlayer) if account and not isGuestAccount(account) then local accName = getAccountName (account) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then if target then local player = getPlayerFromName(target) if (player) then local position = Vector3 (getElementPosition(player)) setElementPosition (thePlayer,position.x,position.y,position.z) end end end end end addCommandHandler( "tp", teleport)
-
Try using outputDebugString to see what the problem is. And try this local antiWeapon = {[0] = true, [1] = true, [2] = true, [4] = true, [5] = true, [6] = true, [8] = true, [9] = true, [10] = true, [12] = true, [14] = true, [34] = true, [35] = true, [36] = true, [37] = true, [38] = true, [16] = true, [17] = true, [18] = true, [39] = true, [14] = true, [40] = true, [41] = true} addEventHandler("onClientPlayerDamage",localPlayer, function (attacker, weapon) if (attacker and getElementType(attacker) == "player" and attacker ~= source) then local pvp = getElementData(source, "PVP") if pvp and antiWeapon[weapon] then cancelEvent() end end end) addEventHandler("onClientPlayerWeaponSwitch", localPlayer, function (prevSlot, newSlot) for _, pvp in ipairs(getElementsByType("player")) do if getElementData(pvp, "PVP") then local px, py, pz = getElementPosition(localPlayer) local x, y, z = getElementPosition(pvp) local dist = getDistanceBetweenPoints3D(px, py, pz, x, y, z) if dist < 300 and antiWeapon[getPedWeapon(getLocalPlayer())] then outputChatBox("No se puede utilizar esta arma en PVP Zona", 255, 0, 0) toggleControl("fire", false) return else toggleControl("fire", true) end end end end) addEventHandler("onClientPlayerWeaponFire", localPlayer, function (weapon, _, _, _, _, _, hitElement ) if hitElement and getElementData(hitElement, "PVP") and antiWeapon[weapon] then outputChatBox("No se puede utilizar esta arma en PVP Zona", 255, 0, 0) toggleControl("fire", false) end end) addEventHandler("onClientPlayerDamage", localPlayer, function (attacker,weapon, bodypart) if (attacker) and (isElement(attacker)) and not (attacker == source) then if (getElementType(attacker) == "vehicle") then attacker = getVehicleController(attacker) or false end if (attacker) and (getElementType(attacker) == "player") then local ff1, ff2, bag1, bag2 = getElementData(source, "friendlyFire"), getElementData(attacker, "friendlyFire"), getElementData(source, "bag"), getElementData(attacker, "bag") if (bag1 or bag2) then return end if (ff1 or ff2) then return end cancelEvent() end end end) addEventHandler("onClientPlayerStealthKill", localPlayer, function (attacker,weapon, bodypart) if (attacker) and (getElementType(attacker) == "player") then local ff1, ff2 = getElementData(source, "friendlyFire"), getElementData(attacker, "friendlyFire") if not (ff1 or ff2) then cancelEvent() end end end) addEventHandler("onClientPlayerSpawn", root, function ( ) colliDable(source) end) addEventHandler("onClientResourceStart", resourceRoot, function ( ) for _, thePlayer in ipairs(getElementsByType("player"))do colliDable(thePlayer) end end) function colliDable(player) if not (player == localPlayer) then setElementCollidableWith(player, localPlayer, false) end end
-
Here is an other cool trick. Using backslashes (\) before single quotes inside single quotes: (to prevent errors when using words with apostrophes). -- Example: local variable = 'don\'t' outputChatBox(variable) -- Result : don't
-
Try this local blips = {} -- blips table function Blip () local players = getElementsByType("player") for id, player in ipairs(players) do local team = getPlayerTeam(player) if team then local r, g, b = getTeamColor(team) if blips[player] then setBlipColor (blips[player],r, g, b,255) else blips[player] = createBlipAttachedTo(player, 0, 2, r, g, b) end end end end setTimer(Blip, 5000, 0) -- destroy the blip (onPlayerQuit,onPlayerLogout,onPlayerWasted) function quit () if blips[source] then -- if the blip exist then destroyElement(blips[source]) -- destroy it blips[source] = nil end end addEventHandler("onPlayerLogout", getRootElement(), quit) addEventHandler("onPlayerQuit", getRootElement(), quit) addEventHandler("onPlayerWasted", getRootElement(), quit)
-
showPlayerHudComponent("vehicle_name", false)
-
Show me your code.
-
Do it by yourself and post your code here.
-
All What you need is -- Function getElementType() getPlayerTeam() getTeamName() -- Events "onPlayerTarget"
-
it can be just like this: without using setTimer x2 setTimer(function (veh) fixVehicle(veh) outputChatBox("Fixed", thePlayer, 255, 0,0) end, 15000, 1, vehicle)
-
you can use sth like this : (exports function) local variable = "" function getVariable() return variable end
-
Try this , untested i'm using the phone function fixVeh (thePlayer,cmd) if thePlayer and isElement(thePlayer) then local account = getPlayerAccount(thePlayer) if account and not isGuestAccount(account) then local accountName = getAccountName (account) if isObjectInACLGroup ( "user."..accountName , aclGetGroup ( "DL3" ) ) then local dimension = getElementDimension(thePlayer) if dimension ~= 366 then if isPedInVehicle(thePlayer) then local vehicle = getPedOccupiedVehicle (thePlayer) fixVehicle ( vehicle ) outputChatBox("Fixed",thePlayer,255,0,0) else outputChatBox("You can't use this ("..cmd..") when your not inside a vehicle!",thePlayer,255,0,0) end else outputChatBox("You can't use this command when you are inside 366 dimension",thePlayer,255,0,0) end end end end end addCommandHandler( "fixv", fixVeh )
-
Check My Tuto about Lua Operators
-
Try this untested i'm using the phone local db = dbConnect("sqlite", "database.db") dbExec (db, "CREATE TABLE IF NOT EXISTS repairkits (account, amount)") -- save repair kits function saveRepairKits(player) if player and isElement(player) then local account = getPlayerAccount(player) if isGuestAccount (account) then local accountName = getAccountName(account) local cur = getElementData(player, "Repair.Kits") or 0 if cur then local results = dbPoll( dbQuery( db, "SELECT * FROM repairkits WHERE account = ?", accountName), -1 ) if results and type(results) == "table" and #results > 0 then dbExec( db, "UPDATE repairkits SET amount = ? WHERE account = ?", tonumber(cur),accountName) else dbExec (db, "INSERT INTO repairkits (account, amount) VALUES (?, ?)",accountName, tonumber(cur)) end end end end end function saveOnQuit() saveRepairKits(source) end addEventHandler ( "onPlayerQuit", root, saveRepairKits ) addEventHandler ( "onPlayerLogout", root, saveRepairKits ) -- load repair kits function LoadRepairs ( _, acc ) local accountName = getAccountName(acc) local tab = getAccountrepairKits(accountName) or 0 if tab then setElementData(source, "Repair.Kits", tonumber(tab)) end end addEventHandler ( "onPlayerLogin", root, LoadRepairs ) -- get Account repair kits function getAccountRepairKits(accName) local results = dbPoll(dbQuery(db, "SELECT * FROM repairkits WHERE account = ?",tostring(accName)), -1) if type(results) == "table" and #results == 0 or not results then return false else return results[1]["amount"] end end
-
Check this one to convert a table into string you can use it to output your table values into log messages. -- convert value to string function table.valueToString (value) if type(value) == "string" then value = string.gsub( value, "\n", "\\n" ) if string.match( string.gsub(value,"[^'\"]",""), '^"+$' ) then return "'" ..value.. "'" end return '"' .. string.gsub(value,'"', '\\"' ) .. '"' else return type(value) == "table" and table.tostring(value) or tostring(value) end end -- convert key to string function table.keyToString (key) if type(key) == "string" and string.match(key, "^[_%a][_%a%d]*$" ) then return key else return "[" ..table.valueToString(key).. "]" end end -- convert table to string function table.tostring(tbl) local result, done = {}, {} for k, v in ipairs(tbl) do table.insert( result,table.valueToString( v ) ) done[ k ] = true end for k, v in pairs( tbl ) do if not done[ k ] then table.insert( result,table.keyToString(k) .. "=" ..table.valueToString( v )) end end return "{" .. table.concat( result, "," ) .. "}" end
-
You are totaly wrong check your code. anyways try this (untested i'm using the phone) function getVehicle(player, command, name ) if player and isElement(player) then if name then -- we get the player element from the nick specified local thePlayer = getPlayerFromName(name) -- if there exists a player with that nick if (not isElement(thePlayer)) then outputChatBox("This player does no longer exist!",player, 255, 0, 0) return end -- if he's in a vehicle if isPedInVehicle(thePlayer) then local vehicle = getPedOccupiedVehicle (thePlayer) outputChatBox(getPlayerName(thePlayer).." drives this vehicle: "..getVehicleName (vehicle),player, 0, 0, 255 ) else outputChatBox(getPlayerName(thePlayer).." isn't in a vehicle.",player, 255, 0, 0 ) end else outputChatBox("[usage] /veh ",player, 255, 0, 0 ) end end end addCommandHandler("veh", getVehicle)
-
try something like this: local words = {"mtasa://","22003"} addEventHandler("onPlayerChat",root, function (msg,type) if type == 0 or type == 1 or type == 2 then for i, v in pairs(words) do if string.find(msg,string.lower(v)) then local playerName = getPlayerName(source) local r,g,b = getPlayerNametagColor(source) outputChatBox(playerName..": advertiser was detected and he got kicked" , root,r,g,b, false) banPlayer (source, false, false, true,"Console", "Don't advertise!") end end end cancelEvent() end )
-
explain your problem better. name = the vehicle name or name = the target name (the player that you are trying to check if he is inside a vehicle or not)
-
I want to explain something all Lua values when used as Booleans evaluate to true, except nil and false. This does not mean that values that evaluate to true are equal to true. If you want to convert a "var" to Boolean, use not not "var". (not nil) --> true (not false) --> true (not 0) --> false (not not nil) --> false
-
'or' not 'and'
-
The url seems to not be working anymore try to use sth ike this local ip = "1.2.3.4" function getServerIP() return ip end