Xwad

Help script

Recommended Posts

My script is not working pls help! DEBUGSCRIPT 3: WARNING: moneyS.lua: Bad argumentum @ "givePkayerMoney' [Expected element at argumentum 1,got nil]

  
function rewardTimer() 
setTimer ( rewardOnRun, 10000, 1 ) 
givePlayerMoney ( source, 3000 ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) 
  
  
  
function rewardOnRun() 
givePlayerMoney ( source, 3000 ) 
setTimer ( rewardTimer, 10000, 1 ) 
end 
  

Share this post


Link to post

Try this:

  
function rewardTimer(player) 
local player = source or player 
setTimer ( rewardOnRun, 10000, 1,player ) 
givePlayerMoney ( player, 3000 ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) 
  
  
  
function rewardOnRun(player) 
givePlayerMoney ( player, 3000 ) 
setTimer ( rewardTimer, 10000, 1,player ) 
end 
  

You did not give any argument to the rewardOnRun() function.

This would make it work, although i am not sure what you are trying to do with the code.

  • Like 1

Share this post


Link to post

Its working thanks! The script is for my new terminator gamemode. I will release it soon. You will see what im doing with the code:D

Share this post


Link to post

one more question. I want to kill the timer if the player die but its not working:/

  
function rewardTimer(player) 
local player = source or player 
local Timer = setTimer ( rewardOnRun, 100, 1,player ) 
givePlayerMoney ( player, 1 ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) 
  
  
  
function rewardOnRun(player) 
givePlayerMoney ( player, 1 ) 
setTimer ( rewardTimer, 100, 1,player ) 
end 
  
  
  
function stopTimer() 
if isTimer ( Timer ) then killTimer ( Timer )  
end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), stopTimer ) 
  

Share this post


Link to post

Remove local here

local Timer = setTimer ( rewardOnRun, 100, 1,player ) 

Share this post


Link to post

This is also working thx! But i have a last last last question xD i want to make that the timer will only start if the player has skin 201. I made it but its not working:/ What shuld be the problem?

  
function rewardTimer(player) 
if getElementModel(source) == 201 then 
local player = source or player 
Timer = setTimer ( rewardOnRun, 100, 1,player ) 
givePlayerMoney ( player, 1 ) 
else 
cancelEvent() 
end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) 
  

Share this post


Link to post
This is also working thx! But i have a last last last question xD i want to make that the timer will only start if the player has skin 201. I made it but its not working:/ What shuld be the problem?

Code 1:

function rewardTimer() 
    local skinId = getElementModel(source) 
    if not skinId == 201 then return end  
    Timer = setTimer ( rewardOnRun, 100, 1,source ) 
    givePlayerMoney (source, 1000 ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) 

or

function rewardTimer (_,_,_,_,_,skin) 
    if not tonumber(skin) == 201 then return end  
    Timer = setTimer ( rewardOnRun, 100, 1,source ) 
    givePlayerMoney (source, 1000 ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(),rewardTimer) 

Share this post


Link to post

if i use this code then the timer is not working:/ so i edited the script like this: but then the timer was starting on all skins again:/

  
function rewardTimer(player) 
local skinId = getElementModel(source) 
if not skinId == 201 then return end 
local player = source or player 
Timer = setTimer ( rewardOnRun, 100, 1,player ) 
givePlayerMoney ( player, 1 ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) 
  
  
  
  
  
  
  
  
  
  
  
function rewardOnRun(player) 
givePlayerMoney ( player, 1 ) 
setTimer ( rewardTimer, 100, 1,player ) 
end 
  
  
  
function stopTimer() 
if isTimer ( Timer ) then killTimer ( Timer ) 
end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), stopTimer ) 
  
  

Share this post


Link to post

one more quesiton. Why is it not giving me the money? The script starts that function with a timer

  
function captureAreaA1(commandName, player) 
local player = source or player 
UA1 = createRadarArea (  -2731.27, -2592, 250, 380, 255, 255, 31, alpha ) 
givePlayerMoney ( player, 1000 ) 
if isElement(markerG1) then 
destroyElement ( GA1 ) 
end 
end 
  

Share this post


Link to post
one more quesiton. Why is it not giving me the money? The script starts that function with a timer
  
function captureAreaA1(commandName, player) 
local player = source or player 
UA1 = createRadarArea (  -2731.27, -2592, 250, 380, 255, 255, 31, alpha ) 
givePlayerMoney ( player, 1000 ) 
if isElement(markerG1) then 
destroyElement ( GA1 ) 
end 
end 
  

if it's client side

wiki: Note: Using this function client side (not recommended) will not change a players money server side.

Share this post


Link to post

Why you have commandName here?

function captureAreaA1(commandName, player) 

Share this post


Link to post

Becaouse i also need commands for that function. And for that i need that argumentum. So why is the givePlayerMoney nkt working?

Share this post


Link to post

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.