Hello, I scripted a long time in Pawn for SA:MP and some days ago I deiced to migrate to MTA:SA.
I need some help to understand the Lua. I already searched tutorials but I not fully understand.
In Pawn I was using this code for an array for player:
enum _:E_MAX_PLAYER_BITS
{
bitsIsDead = 1, // insted of bool (true and false)
...
};
enum _:E_PLAYER_DATA
{
// the 0 of this array is used for bits
intAdminLevel = 1,
...
}
new g_PlayerFlags[MAX_PLAYERS][E_PLAYER_DATA]
#define BitCheck(%0,%1,%2) !! ( ( %0[ %2 ][ 0 ] ) & ( 1 << %1 ) )
#define BitSet(%0,%1,%2,%3) ( (_:%3) && ( ( %0[ %2 ][ 0 ] ) |= ( 1 << %1 ) ) || ( ( %0[ %2 ] [ 0 ] ) &= ~( 1 << %1 ) ) )
public OnPlayerConnect(playerid)
{
g_PlayerFlags[playerid][intAdminLevel] = 3;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
BitSet(g_PlayerFlags, bitsIsDead, playerid, true); // if is posibile to use bit else true or false, is just an example...
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
static intNumber= 1; // Static is a constat value that remain evry time we call OnPlayerStreamIn
prinf("Player have %d %d", BitCheck(g_PlayerFlags, bitsIsDead, playerid), intNumber) // Actualy return int 0/false or 1/true
}
I need some explications about how to convert this from pawn to lua, if is posible to use bits insted of true or false, explain the client scripting and the server scripting better.
Question
bogdyutzu
Hello, I scripted a long time in Pawn for SA:MP and some days ago I deiced to migrate to MTA:SA.
I need some help to understand the Lua. I already searched tutorials but I not fully understand.
In Pawn I was using this code for an array for player:
I need some explications about how to convert this from pawn to lua, if is posible to use bits insted of true or false, explain the client scripting and the server scripting better.
Link to comment
3 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now