Wysłany: 2015-08-03, 10:31
Vxen
Wiek: 27 Na forum: 4087 dni Posty: 293
Piwa : 1299
Siemanko. Mam kod lecz nie wiem czy to jest na dawanie kasy czy na zapis ale po funkcjach widz? ze to jest na dawanie siana. A gdzie w tym kodzie jest komenda? Nie widz? tu addComend.
Oto kod:
_root = getRootElement ()
function giveMoney ( thePlayer , amount )
if ( type ( tonumber ( amount ) ) == "number" and getElementType ( thePlayer ) == "player" ) then
if ( amount == 0 ) then
return true
elseif ( thePlayer and isElement ( thePlayer ) and tonumber ( amount ) > 0 ) then
amount = math . floor ( tonumber ( amount ) )
setElementData ( thePlayer , "money" , getMoney ( thePlayer ) + amount )
local result , error = exports . sql : query_free ( "UPDATE `characters` SET `cash` = cash + " .. amount .. " WHERE charid = '" .. getElementData ( thePlayer , "characterID" ) .. "'" )
if ( result ) then
givePlayerMoney ( thePlayer , amount )
else
return outputDebugString ( error )
end
return true
end
return false
else
return outputDebugString ( "MISSING_ARGUMENTS" )
end
end
function takeMoney ( thePlayer , amount , rest )
amount = tonumber ( amount ) or 0
if amount == 0 then
return true , 0
elseif thePlayer and isElement ( thePlayer ) and amount > 0 then
amount = math . ceil ( amount )
local money = getMoney ( thePlayer )
if rest and amount > money then
amount = money
end
if amount == 0 then
return true , 0
elseif hasMoney ( thePlayer , amount ) then
setElementData ( thePlayer , "money" , money - amount )
if getElementType ( thePlayer ) == "player" then
exports . sql : query_free ( "UPDATE `characters` SET `cash` = cash - " .. amount .. " WHERE charid = '" .. getElementData ( thePlayer , "characterID" ) .. "' " )
takePlayerMoney ( thePlayer , amount )
return true , amount
end
end
return false , 0
end
end
function setMoney ( thePlayer , amount )
amount = tonumber ( amount ) or 0
if thePlayer and isElement ( thePlayer ) and amount >= 0 then
amount = math . floor ( amount )
setElementData ( thePlayer , "money" , amount )
if getElementType ( thePlayer ) == "player" then
exports . sql : query_free ( "UPDATE characters SET money = " .. amount .. " WHERE charid = " .. getElementData ( thePlayer , "dbid" ) )
setPlayerMoney ( thePlayer , amount )
elseif getElementType ( thePlayer ) == "team" then
exports . sql : query_free ( "UPDATE factions SET bankbalance = " .. amount .. " WHERE charid = " .. getElementData ( thePlayer , "id" ) )
end
return true
end
return false
end
function hasMoney ( thePlayer , amount )
amount = tonumber ( amount ) or 0
if thePlayer and isElement ( thePlayer ) and amount >= 0 then
amount = math . floor ( amount )
return getMoney ( thePlayer ) >= amount
end
return false
end
function getMoney ( thePlayer , nocheck )
if not nocheck then
checkMoneyHacks ( thePlayer )
end
return getElementData ( thePlayer , "money" ) or 0
end
function checkMoneyHacks ( thePlayer )
if not getMoney ( thePlayer , true ) or getElementType ( thePlayer ) ~= "player" then return end
local safemoney = getMoney ( thePlayer , true )
local hackmoney = getPlayerMoney ( thePlayer )
if ( safemoney ~= hackmoney ) then
-- banPlayer ( thePlayer , getRootElement (), "Money Hacks: " .. hackmoney .. "$." )
setPlayerMoney ( thePlayer , safemoney )
-- sendMessageToAdmins ( "Possible money hack detected: " .. getPlayerName ( thePlayer ))
return true
else
return false
end
end
Wysłany: 2015-08-03, 10:41
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
Bo to jest na dawanie kasy poprzez mysql
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2015-08-03, 10:43
Vxen
Wiek: 27 Na forum: 4087 dni Posty: 293
Piwa : 1299
I tu niema ?adnej komendy? Po prostu w bazie ustawiamy kase?
Wysłany: 2015-08-03, 10:48
Fanciak
BOT
Wiek: 25 Na forum: 4446 dni Posty: 728
Nick w MP: Fanciak
Piwa : 1572
Wysłany: 2015-08-03, 21:21
Tostuch
Wiek: 27 Na forum: 4931 dni Posty: 483
Nick w MP: Tost
Piwa : 137
Tu s? funkcje nie tylko do dawania, ale og?lnie do zarz?dzania pieni?dzmi gracza.
#Tak troche s?abo u?ywa? tego antyczita valhalli, ?atwo go obej??
Tagi: czy :: zapis?
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: