Untitled diff

Created Diff never expires
6 removals
Words removed9
Total words333
Words removed (%)2.70
20 lines
7 additions
Words added27
Total words351
Words added (%)7.69
21 lines
local command = "#dar"; -- here we define "command" as local variable with a string value of "buff". I defined it as a `local` outside any functions so it is localized to this Lua file only.
local command = "dar"; -- here we define "command" as local variable with a string value of "buff". I defined it as a `local` outside any functions so it is localized to this Lua file only.
local items = {}; -- here i define the variable `buff` as an empty table (Without data).again i have defined it as a local outside any functions so it is localized to this Lua file only.
local items = {}; -- here i define the variable `buff` as an empty table (Without data).again i have defined it as a local outside any functions so it is localized to this Lua file only.


items = {42952,48716}; -- Here I will now store data in the table named `buff`. each id separated by a comma. each spot will be a unique address piece(1,2,3,4,5,6.....) accessed by using the full adress. so to puff a player with buff id '43223' i will use the command `player:AddAura(buff[6], player)` and the player will get buffed with 43223.
items = {42952,48716}; -- Here I will now store data in the table named `buff`. each id separated by a comma. each spot will be a unique address piece(1,2,3,4,5,6.....) accessed by using the full adress. so to puff a player with buff id '43223' i will use the command `player:AddAura(buff[6], player)` and the player will get buffed with 43223.


local function OnEvents(event, player, msg, Type, lang)
local function OnCommand(event, player, cmd)
if(msg:find(command) == 1)then -- here we chech every chat message (converting it to `lower`case) to see if it matches absolute(==) the string stored in the variable `command`.
if(cmd:lower():find(command) == 1)then -- here we chech every chat message (converting it to `lower`case) to see if it matches absolute(==) the string stored in the variable `command`.
if(Player:GetGMRank() < 0) then
if(player:GetGMRank() < 0) then
player:SendBroadcastMessage("Tienes Nivel Suficiente")
player:SendBroadcastMessage("Tienes Nivel Suficiente")
local entry_id; -- here i am defining a variable i will use ONLY inside this function so when its local inside a function it will be localized to only that function and you can make a new variable inside another function using the same name but different stored data.
local entry_id; -- here i am defining a variable i will use ONLY inside this function so when its local inside a function it will be localized to only that function and you can make a new variable inside another function using the same name but different stored data.
for entry_id = 1, #items do -- here i am starting a loop. telling it that entry_id will be from 1 to the max size of the `buff` table (#buff).
for entry_id = 1, #items do -- here i am starting a loop. telling it that entry_id will be from 1 to the max size of the `buff` table (#buff).
Player:AddItem(items[entry_id], 1); -- now using the full address to pinpoint a location of stored data we will apply the data as a buff to the player.
Player:AddItem(items[entry_id], 1); -- now using the full address to pinpoint a location of stored data we will apply the data as a buff to the player.
end -- end for when our current loop is complete and increase entry_id +1 or if entry_id value is the max size for the loop then end and exit the loop.
end -- end for when our current loop is complete and increase entry_id +1 or if entry_id value is the max size for the loop then end and exit the loop.
else
else
player:SendBroadcastMessage("No tienes nivel GM suficiente")
player:SendBroadcastMessage("No tienes nivel GM suficiente")
end
end
return false -- return false to indicate to the core that we dont want to show command not found error
end -- end for the end of our if statement.
end -- end for the end of our if statement.
end -- end of function end.
end -- end of function end.


RegisterPlayerEvent(18, OnEvents)
RegisterPlayerEvent(42, OnCommand)