12p Posted January 21, 2011 Share Posted January 21, 2011 (edited) I want to give money to a player basing in just some letters (like in admin panel). For example: Player Objetive: Maurize Word on Command for Player: Mau Well, it doesn't find any player... addCommandHandler ("dardinero", function (player,_,destiny,cash) if destiny and cash then if getPlayerMoney (player) >= tonumber(cash) then local matchPlayers = {} local players = getElementsByType ("player") for i,p in ipairs (players) do local name = getPlayerName (p) if string.find(destiny,name) then table.insert(matchPlayers,p) outputChatBox ("test") end end if table.getn(matchPlayers) == 1 then takePlayerMoney (player,tonumber(cash)) givePlayerMoney (matchPlayers[1],tonumber(cash)) outputChatBox ("INFO: Enviaste $"..cash.." a "..getPlayerName(matchPlayers[1])..".",player,0,255,0) outputChatBox ("INFO: Recibiste $"..cash.." de "..getPlayerName(player)..".",matchPlayers[1],0,255,0) elseif table.getn(matchPlayers) > 1 then outputChatBox ("ERROR: Hay mas de un jugador con este nombre.",player,255,0,0) else outputChatBox ("ERROR: No hay jugadores con este nombre.",player,255,0,0) end else outputChatBox ("ERROR: Tus fondos son insuficientes.",player,255,0,0) end else outputChatBox ("ERROR: Falta algun argumento.",player,255,0,0) end end) Edited January 21, 2011 by Guest Link to comment
12p Posted January 21, 2011 Author Share Posted January 21, 2011 Ok I fixed that but still doesn't insert anything into the table. What's wrong? Link to comment
DakiLLa Posted January 21, 2011 Share Posted January 21, 2011 I guess it should be string.find(name, destiny) since you are searching any matches with 'destiny' in player's name. 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