i514x Posted December 20, 2011 Share Posted December 20, 2011 HI, I've been playing SA-MP for a while now but never knew MTA is just so freaking awesome. So now I play MTA SA and I started making my own server, Lua is a bit of pain coz of the syntax but i'm getting a hang of it. My question is how can I loop through all players in a for loop? What I want accomplish is make a getPlayerSource function by player's name. @Edit: I have found getDeadPlayers and getAlivePlayers but no such function as getPlayers, if I join those tables would it be ok? Anyways is there any better way? Link to comment
TwiX! Posted December 20, 2011 Share Posted December 20, 2011 u want get all players? getPlayerCount () not? https://wiki.multitheftauto.com/wiki/GetPlayerCount all players local players = getElementsByType ( "player" ) https://wiki.multitheftauto.com/wiki/GetElementsByType Link to comment
TAPL Posted December 20, 2011 Share Posted December 20, 2011 for id, player in ipairs(getElementsByType("player")) do -- your code here end and maybe you mean getPlayerFromName Link to comment
i514x Posted December 20, 2011 Author Share Posted December 20, 2011 local players = getElementsByType ( "player" ) https://wiki.multitheftauto.com/wiki/GetElementsByType for id, player in ipairs(getElementsByType("player")) do -- your code here end Thats what I meant getPlayerFromName Yeah I wanted to make that function but didn't know it actually exists, MTA has so many functions compared to SA-MP Link to comment
arezu Posted December 20, 2011 Share Posted December 20, 2011 So now I play MTA SA and I started making my own server, Lua is a bit of pain coz of the syntax but i'm getting a hang of it. Pawn looks like Java and c, and Lua looks like... action script. Do you seriously mean that Pawn is easier than Lua? Pawn doesn't even look like a scripting language . Link to comment
TwiX! Posted December 21, 2011 Share Posted December 21, 2011 getPlayerFromName Yeah I wanted to make that function but didn't know it actually exists, MTA has so many functions compared to SA-MP https://wiki.multitheftauto.com/wiki/GetPlayerFromName Link to comment
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