First of all i wish u guys a really really great day around here!
I really like to know how i can script lets say something like /weapon or something.
What i mean is how can i make a command that uses /text and then a identifier after it.
Im not new at scripting at all, but lua is kinda new to me.
Thanks haha thats more what i need!
Now i understand the way of scripting between client side and server side.
But is there a way like to make the command with use of an player id or something?
-- SERVERSIDED
AddEventHandler('chatMessage', function(source, n, msg)
local Message = string.lower(msg)
local MessageParts = stringsplit(Message, " ") --The Seperator Is A Blank Space
if (MessageParts[1] == "/weapon") then
TriggerClientEvent('Weapon', source, MessageParts[2]) --I added the second Argument, the **2** from the message
CancelEvent()
end
end)
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
-- CLIENTSIDED
-- Register a network event
RegisterNetEvent('Weapon')
AddEventHandler('Weapon', function(number) --I also added the argument here
--do stuff here with the arguments, for example outputting it
drawNotification(tostring(number))
end)
function drawNotification(text) --Just Don't Edit!
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end