Jump to content

Please help me.. whats wrong ?


NeedSumHelp

Recommended Posts

Posted
function MoneyForWinner() 
   local alivePlayers = getAlivePlayers() 
   if #alivePlayers == 1 then  
   local playername = getPlayerName( alivePlayers[1] ) 
   local serial = getPlayerSerial(alivePlayers[1]) 
   local Cash = executeSQLSelect( "GREENTHING", "Cash","serial = '" .. serial .. "'") 
    
   Cashs = tonumber(Cash[1]["Cash"]) + 150 
    
   setElementData(alivePlayers[1] ,"data.playername",playername,true) 
   setElementData(alivePlayers[1] ,"data.Cash",Cashs,true) 
         
   executeSQLUpdate ( "GREENTHING", "Cash = '"..Cashs.."'","serial = '" .. serial .. "'") 
   end  
end 
addEventHandler("onPlayerWasted", rootElement  , MoneyForWinner) 

it says bad argument @ getplayerserial and getplayername

This should give winner 150 rubla but w/e its not doing it and im sure everything is correct.. what i should do ?

Posted

im not sure if you should use 1 as table index.

try:

if #alivePlayers == 1 then 
for key,val in ipairs(alivePlayers) do 
  -- your stuff here 
  -- val is player element 
end 

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

show full code pls

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
    function MoneyForWinner() 
       local alivePlayers = getAlivePlayers() 
       if #alivePlayers == 1 then 
for key,val in ipairs(alivePlayers) do 
      local playername = getPlayerName( val[1] ) 
      local serial = getPlayerSerial(val[1]) 
   local Cash = executeSQLSelect( "GREENTHING", "Cash","serial = '" .. serial .. "'") 
       
      Cashs = tonumber(Cash[1]["Cash"]) + 150 
        
     setElementData(val[1] ,"data.playername",playername,true) 
      setElementData(val[1] ,"data.Cash",Cashs,true) 
           
      executeSQLUpdate ( "GREENTHING", "Cash = '"..Cashs.."'","serial = '" .. serial .. "'") 
      end 
   end 
   addEventHandler("onPlayerWasted", rootElement  , MoneyForWinner) 

Or still error.. attempt to index local 'val' (a userdata value)

line

   local playername = getPlayerName( val[1] ) 

Posted

replace val[1] with only val

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

ah right, tought it will change it for everyone but yeah u were right ;) thanks for very very fast help.. never seen such speed in forums :) im serious ur the best moderator i ever seen

and i dint try to rise ur ego ^^ ok again, thank you

Posted

umm, well, thanks, being some kind of no-life makes my replies fast :P

hope i'll get new job soon..

whatever..

glad i helped

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...