Jump to content

Any possibilities to use PAWN as the scripting language?


TopAz

Recommended Posts

It seems you are a new user, and have come from that other mod, well congratulations for joining this modification and welcome. Lua is much faster and doesn't require compiling, if you use the amx resource you are building a wall between the awesomeness and your server. I recommend you to learn Lua, you can ask questions here any time you feel like and take a look at the tutorials too.

Link to comment
It seems you are a new user, and have come from that other mod, well congratulations for joining this modification and welcome. Lua is much faster and doesn't require compiling, if you use the amx resource you are building a wall between the awesomeness and your server. I recommend you to learn Lua, you can ask questions here any time you feel like and take a look at the tutorials too.

I am a PAWN and C# programmer but Lua is not my type language. It's a very close language.

Link to comment
local unacceptedNames = { 
['Bill']=false, 
[ 'Sex']=true, 
 ['Orange']=true, 
['Kiwi']=true, 
 ['Dora_the_explorer']=true, 
[ '41snakesolid']=true, 
[ 'lelee']=true 
  
addEventHandler( 'onPlayerJoin', root, function() 
    if unacceptedNames[ string.lower( getPlayerName(source) ) ] then 
         kickPlayer(source) 
     end 
end) 

This gets the players name when he joins, puts it in lowercase, checks the array/table to see if it has an index with the name AND a value other than false.

So if my name is Dora_the_explorer then I will be kicked.

If my name is Bill, then i won't be kicked

( i dont see why i should put bill, but just to make you understand the table concept too )

Link to comment
local unacceptedNames = { 
['Bill']=false, 
[ 'Sex']=true, 
 ['Orange']=true, 
['Kiwi']=true, 
 ['Dora_the_explorer']=true, 
[ '41snakesolid']=true, 
[ 'lelee']=true 
  
addEventHandler( 'onPlayerJoin', root, function() 
    if unacceptedNames[ string.lower( getPlayerName(source) ) ] then 
         kickPlayer(source) 
     end 
end) 

This gets the players name when he joins, puts it in lowercase, checks the array/table to see if it has an index with the name AND a value other than false.

So if my name is Dora_the_explorer then I will be kicked.

If my name is Bill, then i won't be kicked

( i dont see why i should put bill, but just to make you understand the table concept too )

you wont be kicked with "Dora_the_explorer" name, because that table key has a capital letter.

same with all other names, except the last 2.

and the whole thing wont work anyway because you forgot to close the table constructor.

Link to comment
local unacceptedNames = { 
['Bill']=false, 
[ 'Sex']=true, 
 ['Orange']=true, 
['Kiwi']=true, 
 ['Dora_the_explorer']=true, 
[ '41snakesolid']=true, 
[ 'lelee']=true 
  
addEventHandler( 'onPlayerJoin', root, function() 
    if unacceptedNames[ string.lower( getPlayerName(source) ) ] then 
         kickPlayer(source) 
     end 
end) 

This gets the players name when he joins, puts it in lowercase, checks the array/table to see if it has an index with the name AND a value other than false.

So if my name is Dora_the_explorer then I will be kicked.

If my name is Bill, then i won't be kicked

( i dont see why i should put bill, but just to make you understand the table concept too )

you wont be kicked with "Dora_the_explorer" name, because that table key has a capital letter.

same with all other names, except the last 2.

and the whole thing wont work anyway because you forgot to close the table constructor.

But wouldn't string.lower change all the character's casing?

Link to comment

yes, sorry, do this;

  
local unacceptedNames = { 
['bill']=false, 
[ 'sex']=true, 
 ['orange']=true, 
['kiwi']=true, 
 ['dora_the_explorer']=true, 
[ '41snakesolid']=true, 
[ 'lelee']=true 
 } 
  
  
addEventHandler( 'onPlayerJoin', root, function() 
    if unacceptedNames[ string.lower( getPlayerName(source) ) ] then 
         kickPlayer(source) 
     end 
end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...