Jump to content

[HELP] Script not work


1LoL1

Recommended Posts

Hello, i created script but how i can delete amount 1.x i want only 1-999999999 not 1.1 - 1.999999

Please can anyone help me?

function www (source,command,amount) 
local money = getPlayerMoney(source) 
local amount = tonumber(amount) 
if (amount) then 
if tonumber(money) >= amount and amount > 0 then 
setElementData(test, "www", (getElementData(test, "www") or 0) + amount) 
takePlayerMoney(source, amount) 
outputChatBox("Player "..string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "").." -->"..convertNumber(amount).."$!", getRootElement(), 255, 0, 0, true) 
else 
outputChatBox("...", source, 255, 0, 0, true) 
end 
end 
end 
addCommandHandler("ddr", www) 

Link to comment

I have window but how i can defined of server-side ped money to client-side -> window

function ped () 
mmm = createPed(0, -2715.1787109375,1330.7080078125,7.1677074432373, 270) 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ped) 

What i must use here?:

local money = getPlayerMoney(mmm)  

or what please help? :(

Link to comment

Actully you can, but you have to create your own money system using

setElementData 
getElementData 

or whatever method you want to

Here's an example

function buySomthing(element) 
    if getElementData(element) >= 500 then 
        takeElementMoney(element,500) 
    end 
end 
  
-------------- Our new money system 
  
function getElementMoney(element) 
    if isElement(element) then 
        return getElementData(element,"Money") or 0 
    end 
    return false 
end 
  
function setElementMoney(element,money) 
    if isElement(element) and type(money) == "number" then 
        return setElementData(element,"Money",money) 
    end 
    return false 
end 
  
function takeElementMoney(element,money) 
    if isElement(element) and type(money) == "number" then 
        return setElementMoney(element,getElementMoney(element)-money)) 
    end 
    return false 
end 
  
function giveElementMoney(element,money) 
    if isElement(element) and type(money) == "number" then 
        return setElementMoney(element,getElementMoney(element)+money)) 
    end 
    return false 
end 

Link to comment
Actully you can, but you have to create your own money system using
setElementData 
getElementData 

or whatever method you want to

Here's an example

function buySomthing(element) 
    if getElementData(element) >= 500 then 
        takeElementMoney(element,500) 
    end 
end 
  
-------------- Our new money system 
  
function getElementMoney(element) 
    if isElement(element) then 
        return getElementData(element,"Money") or 0 
    end 
    return false 
end 
  
function setElementMoney(element,money) 
    if isElement(element) and type(money) == "number" then 
        return setElementData(element,"Money",money) 
    end 
    return false 
end 
  
function takeElementMoney(element,money) 
    if isElement(element) and type(money) == "number" then 
        return setElementMoney(element,getElementMoney(element)-money)) 
    end 
    return false 
end 
  
function giveElementMoney(element,money) 
    if isElement(element) and type(money) == "number" then 
        return setElementMoney(element,getElementMoney(element)+money)) 
    end 
    return false 
end 

But this not work :(

ERROR: ERROR: Bad argument #1 to "floor" (number expected, got nil)

function www (source,element,command,amount) 
local money = getPlayerMoney(source) 
local amount = tonumber(math.floor(amount)) 
if amount then 
if tonumber(money) >= amount and amount > 0 then 
setElementData(element, "data", (getElementData(element, "data") or 0) + amount) 
takePlayerMoney(source, amount) 
outputChatBox("Player "..string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "").." --> "..amount.."$", getRootElement(), 255, 0, 0, true) 
else 
outputChatBox("...", source, 255, 0, 0, true) 
end 
end 
end 
addCommandHandler("ww", www) 

Link to comment
delete "element" from line 1

then replace element with source in line 6

change line 3 to

local amount = math.floor(tonumber(amount)) 

because amount is string and you can't use "math.floor" which work only with numbers before you convert amount to number

But i don't want to player i have firm system.

Link to comment
  • Moderators
what's firm?

Company system. So i need takePlayerMoney from player and givePlayerMoney to company.

That has at the moment nothing to do with this. You are using addCommandHandler and not the company resource to trigger this function.

Link to comment
what's firm?

Company system. So i need takePlayerMoney from player and givePlayerMoney to company.

That has at the moment nothing to do with this. You are using addCommandHandler and not the company resource to trigger this function.

What? i want to with addCommandHandler send $ to company..

Link to comment

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...