^Dev-PoinT^ Posted October 5, 2011 Share Posted October 5, 2011 Hi all i have made This function() local pC= getAlivePlayers() if ( pC >= 1,3) then for id, player in ipairs ( getElementsByType ( "player" ) ) do setPlayerArmor ( player, 50 ) outputChatBox(..getPlayerName..Has won 50% Armor For Alive on Round,root,") outputChatBox("You Have won Free Armor for be Alive in Round",getLocalPlayer() end end if 1 player or 3 Alive in Round give Them Armor with msg Please Fix and tell me what is my errors Link to comment
CapY Posted October 5, 2011 Share Posted October 5, 2011 (edited) Hi all i have made This function() local pC= getAlivePlayers() if ( pC >= 1,3) then for id, player in ipairs ( getElementsByType ( "player" ) ) do setPlayerArmor ( player, 50 ) outputChatBox(..getPlayerName..Has won 50% Armor For Alive on Round,root,") outputChatBox("You Have won Free Armor for be Alive in Round",getLocalPlayer() end end if 1 player or 3 Alive in Round give Them Armor with msg Please Fix and tell me what is my errors if ( pC >= 1) then replace that with old one. Edit function() local pC= getAlivePlayers() if ( pC >= 1) then for id, player in ipairs ( getElementsByType ( "player" ) ) do setPlayerArmor ( player, 50 ) outputChatBox(getPlayerName.."Has won 50% Armor For Alive on Round",root,0 , 255, 0) outputChatBox("You Have won Free Armor for be Alive in Round", source()) end Try that. Edited October 5, 2011 by Guest Link to comment
^Dev-PoinT^ Posted October 5, 2011 Author Share Posted October 5, 2011 yes but i i want it if 1,2,3 Players Not just 1 player Link to comment
CapY Posted October 5, 2011 Share Posted October 5, 2011 Then why you don't do it onPlayerSpawn ? Does it work atleast ? Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 it does not, because it's a total mess. Link to comment
CapY Posted October 5, 2011 Share Posted October 5, 2011 it does not, because it's a total mess. I've just corrected errors. Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 it does not, because it's a total mess. I've just corrected errors. almost every line in this script has errors, and the whole thing has no logic to it. you didnt "fixed" it all. and even then ">= 1" is not what topic starter wants. function() -- no function name local pC= getAlivePlayers() -- SERVER function, which returns a TABLE if ( pC >= 1 ) then -- not gonna work, pC is a TABLE for id, player in ipairs ( getElementsByType ( "player" ) ) do -- why ALL players now? setPlayerArmor ( player, 50 ) -- probably single correct line (oh wait, its not: setPedArmor) outputChatBox(..getPlayerName..Has won 50% Armor For Alive on Round,root,") -- ↑ no quotes, no function call, total mess at its finest outputChatBox("You Have won Free Armor for be Alive in Round",getLocalPlayer() -- missing parenthesis -- ↑ also getLocalPlayer is a CLIENT function, and you have SERVER function above. wtf? end end -- no end for the function -- PS oh look even forum lua highligther is freaked out. Link to comment
^Dev-PoinT^ Posted October 5, 2011 Author Share Posted October 5, 2011 (edited) what about This Pleae Help function() local pC= getAlivePlayers() if ( pC >= 1 or 2 or 3) then for id, player in ipairs ( getElementsByType ( "player" ) ) do setPlayerArmor ( player, 50 ) outputChatBox(getPlayerName.."Has won 50% Armor For Alive on Round",root,0 , 255, 0) outputChatBox(getPlayerName.."Has won 50% Armor For Alive on Round",root,()255 , 255, 0) end end Edited October 5, 2011 by Guest Link to comment
CapY Posted October 5, 2011 Share Posted October 5, 2011 What Aibo said ? Did you readed his post ? You can't have server and client side functions together. Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 "if ( pC >= 1 or 2 or 3) then" will always return true (well in your case it will return table-number comparison error), read about operator precedence in Lua. and logical operators. and Lua. Link to comment
^Dev-PoinT^ Posted October 5, 2011 Author Share Posted October 5, 2011 what i do then ? can you fix it if Alive Player = 3 give Them Armor with msg Link to comment
CapY Posted October 5, 2011 Share Posted October 5, 2011 https://forum.multitheftauto.com/viewtop ... 169781e00f It has perfect debug , Dev-Point try it. Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 what i do then ?can you fix it if Alive Player = 3 give Them Armor with msg and then you go to the scripting basics function giveArmor() local pC= getAlivePlayers() if (#pC >= 1 and #pC <= 3) then for id, player in ipairs(pC) do setPedArmor(player, 50) outputChatBox(getPlayerName(player).." has won 50% Armor For Alive on Round", root) outputChatBox("You Have won Free Armor for be Alive in Round", player) end end end Link to comment
TAPL Posted October 5, 2011 Share Posted October 5, 2011 Dev-PoinT, where is the event? or you think the script will run his self? Link to comment
^Dev-PoinT^ Posted October 5, 2011 Author Share Posted October 5, 2011 Abio Thx For tell me my errors and see This function giveArmor() local pC= getAlivePlayers() if (#pC >= 1 and #pC <= 3) then for id, player in ipairs(pC) do setPedArmor(player, 50) outputChatBox(getPlayerName(player).." has won 50% Armor For Alive on Round", root),0,255,0 outputChatBox("You Have won Free Armor for be Alive in Round", player),255,255,0 end end end addEventHandler( "onPlayerWasted", getRootElement( ), function() setPedArmor(player, 0) end) Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 why you put arguments outside function call? this is going nowhere. function giveArmor() local pC= getAlivePlayers() if (#pC >= 1 and #pC <= 3) then for id, player in ipairs(pC) do setPedArmor(player, 50) outputChatBox(getPlayerName(player).." has won 50% Armor For Alive on Round", root, 0, 255, 0) outputChatBox("You Have won Free Armor for be Alive in Round", player, 255, 255, 0) end end setPedArmor(source, 0) end addEventHandler("onPlayerWasted", root, giveArmor) Link to comment
^Dev-PoinT^ Posted October 5, 2011 Author Share Posted October 5, 2011 Thx Dude For help 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