easy help, lua

Joined
Dec 4, 2018
Messages
4
Likes
0
Points
1
1
#1
I need my script to check the player's nick, and if it is not one of the ones I have listed, he will take action
 

ItsRobinson

Well-Known Member
Joined
Nov 16, 2017
Messages
104
Likes
19
Points
33
#2
Need more information than that. Are you typing a name with a command or is the name coming from the chat? What action is to be taken?
 

ItsRobinson

Well-Known Member
Joined
Nov 16, 2017
Messages
104
Likes
19
Points
33
#4
So you're saying, you want something to happen when the script loads, if your name is online?
 
OP
OP
J
Joined
Dec 4, 2018
Messages
4
Likes
0
Points
1
1
#5
So you're saying, you want something to happen when the script loads, if your name is online?
you didn't understand, i'm making a private script, and i just want the nicknames i choose to be able to use it

for example: my nick: SpinQuatts, I will be able to use the script

and the others, even having the script, will only be able to use it if they have the nickname "registered" in the script
 

ItsRobinson

Well-Known Member
Joined
Nov 16, 2017
Messages
104
Likes
19
Points
33
#6
Right okay, but you realise that lua is a open source, meaning anyone can edit it in any text editor. So you can put names into the script, but if the script is sent on, anyone can just add their name to it.

You can compile LUA files, but they're easy to fairly easy to decompile. Same with CLEO.

For something like this, you would be best with an ASI, exe or an SF plugin. But considering you don't even know how to write a basic LUA mod, you probably won't be able to make any of those.

Nevertheless:
PHP:
require "lib.sampfuncs"

function main()
    if not isSampfuncsLoaded() then return end
    if not isSampLoaded() then return end
    
    AllowScriptToRun = false
    
    pID = sampGetPlayerIdByCharHandle(playerPed)
    pName = sampGetPlayerNickname(pID)
    if text:find("SpinQuatts") or text:find("Robinson") then
        AllowScriptToRun = true
    end
    
    while true do
        wait(0)
        if AllowScriptToRun then
            -- Your script
        end
    end
end
Not tested but should work
 
Last edited:
Top