Ahh sweet cheers, i did start working on one and i am just waiting for alpha 1.0045 to re download (had too many issues with 1.005 and just have some quick new scripter questions for anyone that might answer, and conjured your scripts help me identify some problems i had already so thankyou
well first here's the script:
note the variable currentcash is declared in another script
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collected cash system
-- Standard player distance math
function cash_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 80 then
--Display Text
Prompt("Press E to pickup cash, cash =" .. currentcash);
if g_KeyPressE == 1 then
-- Hopefully this will casue the player to pickup a random amount of cash between 100 and 5000
-- Later i will try and make this in clean multiples off 100
currentcash = currentcash + math.random(100,5000);
Destroy(e);
end
end
-- Detect if player push the E key
if g_KeyPressE == 0 then
pressed = 0;
end
end
and my questions:
1. is the detect if player pushed key at all needed in there
ok i have removed my question for math.random as i have just been testing and comfirmed that using:
currentcash = currentcash + (math.random(10,50) * 10);
will give you nice clean numbers in multiples of 10 i.e will generate a random number between 10 and 50 such as 14, then multiply it by 10 to form 140. Just thought would put this here if anyone was wondering like i was before