bogdyutzu Posted December 25, 2012 Share Posted December 25, 2012 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. Link to comment
0 MIKI785 Posted December 25, 2012 Share Posted December 25, 2012 I don't understand pawn, but you are trying to save some players data in array? In Lua, it's better to use setElementData, as it's synced between server and clients. Visit wiki: https://wiki.multitheftauto.com Btw. this should be in scripting section. Link to comment
0 myonlake Posted December 30, 2012 Share Posted December 30, 2012 MIKI785 said: I don't understand pawn, but you are trying to save some players data in array? In Lua, it's better to use setElementData, as it's synced between server and clients. Visit wiki: https://wiki.multitheftauto.com Btw. this should be in scripting section. Lua does not have a function called "setElementData". It's a MTA function, do not connect MTA with Lua, while those two are completely different things. You can save player data in tables and synchronize them between clients and servers. Link to comment
0 Anderl Posted January 5, 2013 Share Posted January 5, 2013 Client-side functions run in client's MTA:SA process, server-side functions run in the MTA:SA server. In Lua, you use only the boolean operators "true", "false" and "nil". Would be better if you explain what you are trying to do and we'll give you tips of how to do it. But I can tell you one thing: Anything you do in SA:MP, you do it faster and simpler in MTA:SA. Link to comment
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