Eitho, po co tworzysz funkcj? skoro od razu mo?na j? da? w eventHandlerze
HeviK*,
addCommandHandler("setXP",function(sourcePlayer,cmd,player,xp)
if player and xp then
local target = getPlayerFromName(player);
if target then
setAccountData(target, "exp", xp);
setElementData(target, "exp", xp);
outputChatBox("Ustawiono "..xp.." punkt?w XP graczowi "..player,sourcePlayer);
else
outputChatBox("Nie znaleziono gracza!",sourcePlayer);
end
else
outputChatBox("Nie poda?e? nicku gracza lub punkt?w do?wiadczenia!",sourcePlayer);
end
end)
Komenda dzia?a i przyznaje xp, ale nie zapisuje go
[ Dodano: 2019-01-03, 21:21 ]
Moja propozycja:
function systemEXP(player, xp)
local account = getPlayerAccount(player);
local eksp2= getAccountData(account, "exp") or 0;
local eksp= eksp2+ xp;
setAccountData(account, "exp", eksp);
setElementData(player, "exp", eksp);
end
------------------------------------------
function setXP(player, xp)
if not player or not xp then
return false
end
local account = getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
if not account then
return false
end
setAccountData(account, 'exp', xp)
if getPlayerFromName(player) then
setElementData(player, 'exp', xp)
end
return true
end
function giveXP(player, givexp)
if not player or not givexp then
return false
end
local account = getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
if not account then
return false
end
local xp = getAccountData(account, 'exp') or 0
setAccountData(account, 'exp', xp+givexp)
if getPlayerFromName(player) then
setElementData(player, 'exp', xp+givexp)
end
return true
end
function takeXP(player, takexp)
if not player or not takexp then
return false
end
local account = getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
if not account then
return false
end
local xp = getAccountData(account, 'exp') or 0
setAccountData(account, 'exp', xp-takexp)
if getPlayerFromName(player) then
setElementData(player, 'exp', xp-takexp)
end
return true
end
addCommandHandler('setXP', function(plr, cmd, targetPlayer, xp)
setXP(targetPlayer, xp)
end)
addCommandHandler('giveXP', function(plr, cmd, targetPlayer, xp)
giveXP(targetPlayer, xp)
end)
addCommandHandler('takeXP', function(plr, cmd, targetPlayer, xp)
takeXP(targetPlayer, xp)
end)
Powinno dzia?a? bez wzgl?du czy gracz jest online czy nie, nie testowane.
Wywala mi b??d, ?e nie wyszukuje mi argumentu 1, czyli /setXP NICK, XP (nicku nie wyszukuje)
addEventHandler("onPlayerLogin", root, function()
local acc = getPlayerAccount(source);
setElementData(source, "exp", getAccountData(acc, "exp") or 0);
end);
Zapis by?, tylko nie podawalem go. Je?li ustawie komenda /setXP to ustawi mi xp ale jak zabije np zombie to przed ustawieniem mialem 10 xp ustawie 20 i zabije zombie to jest 11 (za zabicie jest +1)
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach