mastermax777 Posted May 16, 2011 Posted May 16, 2011 if anyone here knows pawno there is a command that i can do for example new bool:first[MAX_PLAYERS]; so my question how do i make global variable for all players (a boolean, only true and false ) so then on player spawn i can do... first[playerid] = true; --or if(first[thePlayer]==true) --etc... and so on.. i guess i mean by max_players is for each client or something like that if anybody have understood me ?
karlis Posted May 17, 2011 Posted May 17, 2011 in lua you don't need to define variables, you just make them players = { } players[1] = true players[2] = false --or players = { true, false } but mta doesn't have build in player id system. so for all players table you need to use players = getElementsByType("player") for key,value in pairs(players) do --do what you want end
mastermax777 Posted May 17, 2011 Author Posted May 17, 2011 (edited) sry double post Edited May 17, 2011 by Guest
mastermax777 Posted May 17, 2011 Author Posted May 17, 2011 ok so how can i do something like this in lua? firstspawn = {} function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) if(firstspawn[source]) --do stuff... firstspawn[source] = false; end end addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn )
mastermax777 Posted May 17, 2011 Author Posted May 17, 2011 why u ask ? i know it doesnt work ! pls help me dont post useless -.- if(firstspawn[source]) then firstspawn[source] = false; givePlayerMoney ( source, 10000 ) outputChatBox("called?") createBlipAttachedTo (source, 56) end
karlis Posted May 17, 2011 Posted May 17, 2011 server, and before that you have to use players=getElementsByType("player")
Arran Posted May 17, 2011 Posted May 17, 2011 if(firstspawn[source]) then -- won't pass, ever. if (not firstspawn[source]) then -- use this instead firstspawn[source] = true -- do this after their first spawn so it won't run on their 2nd spawn.
mastermax777 Posted May 17, 2011 Author Posted May 17, 2011 finally, someone... thank u guys especially karlis and aaran i solved it...
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