Guten Tag liebe Community,
ich habe hier ein Race Script, dass die Stats anzeigt...
nun komm ich aber nicht weiter. Wenn ich /st eingebe kommt beim debugscript: Error: wac-script\Player.lua:114: attempt to call global 'getAccountData' (a nil value).
Auch wenn ich /cash oder /rank eingeben kommt der gleiche Fehler mit getAccountData, aber in einer anderen Zeile.
Schonmal Danke im Vorraus.
Lua
local GuestError = "Sorry, you are a guest. Please register and login!"
local GuestError2 = "Sorry, but your target is not logged in!"
local BetError = "Correct syntax is: /bet [player] [amount]"
local BetErrorM = "You don't have enough cash."
local Bet = 0
function findPlayer(namepart)
for i, player in ipairs(getElementsByType("player")) do
local name = getPlayerName(player)
if string.find(name:lower(), namepart:lower(), 1, true) then return player, name end
end
return false
end
function Rank(player, command, who)
if who then
local GetPlayer, PlayerName = findPlayer(who)
if GetPlayer then
if isGuestAccount(getPlayerAccount ( GetPlayer )) then
--outputChatBox("* #FFFFFF" .. PlayerName .. "#0fc0fc is cant save, becuase he is guest!", getRootElement(), 255, 255, 255, true)
outputChatBox(GuestError2, player, 255, 0, 0, true)
else
local getAcc = getPlayerAccount ( GetPlayer )
local getPointsPlayer = getAccountData(getAcc, "Points")
local getRankPlayer = getAccountData(getAcc, "Rank")
local Exp = getAccountData(getAcc, "Exp")
outputChatBox("* #FFFFFF" .. PlayerName .. "#0fc0fc is '#FFFFFF" .. getRankPlayer .. "#0fc0fc' rank (" .. RankPoints[Exp] - getPointsPlayer .. " points needed for rank '" .. Ranks[Exp + 1] .. "')!", getRootElement(), 255, 255, 255, true)
end
end
else
if not isGuestAccount(getPlayerAccount ( source ) ) then
local getAcc = getPlayerAccount ( source )
local getPointsPlayer = getAccountData(getAcc, "Points")
local getRankPlayer = getAccountData(getAcc, "Rank")
local Exp = getAccountData(getAcc, "Exp")
outputChatBox("* #FFFFFF" .. getPlayerName(source) .. "#0fc0fc is '#FFFFFF" .. getRankPlayer .. "#0fc0fc' rank (" .. RankPoints[Exp] - getPointsPlayer .. " points needed for rank '" .. Ranks[Exp + 1] .. "')!", getRootElement(), 255, 255, 255, true)
else
outputChatBox(GuestError, source, 255, 0, 0, true)
end
end
end
addCommandHandler("rank",Rank)
function Cash(player, command, who)
if who then
local GetPlayer, PlayerName = findPlayer(who)
if GetPlayer then
if isGuestAccount(getPlayerAccount ( GetPlayer )) then
outputChatBox(GuestError2, player, 255, 0, 0, true)
else
local getAcc = getPlayerAccount ( GetPlayer )
local getCashPlayer = getAccountData(getAcc, "Cash")
outputChatBox("* #FFFFFF" .. PlayerName .. "#0fc0fc has #FFFFFF" .. getCashPlayer .. "$#0fc0fc!", getRootElement(), 255, 255, 255, true)
end
end
else
if not isGuestAccount(getPlayerAccount ( source ) ) then
local getAcc = getPlayerAccount ( source )
local getCashPlayer = getAccountData(getAcc, "Cash")
outputChatBox("* #FFFFFF" .. getPlayerName(source) .. "#0fc0fc has #FFFFFF" .. getCashPlayer .. "$#0fc0fc!", getRootElement(), 255, 255, 255, true)
else
outputChatBox(GuestError, source, 255, 0, 0, true)
end
end
end
addCommandHandler("cash",Cash)
function Points(player, command, who)
if who then
local GetPlayer, PlayerName = findPlayer(who)
if GetPlayer then
if isGuestAccount(getPlayerAccount ( GetPlayer )) then
outputChatBox(GuestError2, player, 255, 0, 0, true)
else
local getAcc = getPlayerAccount ( GetPlayer )
local getPointsPlayer = getAccountData(getAcc, "Points")
outputChatBox("* #FFFFFF" .. PlayerName .. "#0fc0fc has #FFFFFF" .. getPointsPlayer .. "#0fc0fc points!", getRootElement(), 255, 255, 255, true)
end
end
else
if not isGuestAccount(getPlayerAccount ( source ) ) then
local getAcc = getPlayerAccount ( source )
local getPointsPlayer = getAccountData(getAcc, "Points")
outputChatBox("* #FFFFFF" .. getPlayerName(source) .. "#0fc0fc has #FFFFFF" .. getPointsPlayer .. "#0fc0fc points!", getRootElement(), 255, 255, 255, true)
else
outputChatBox(GuestError, source, 255, 0, 0, true)
end
end
end
addCommandHandler("points",Points)
--outputChatBox(getPlayerName(player).."'s Stats, Points: "data.points" - Wins: "data.wins" - Loses: "data.lost" - Cash: $"data.cash" - Rank: "data.rank",root,0,255,255)
function Stats(source, command, who)
if who then
local GetPlayer, PlayerName = findPlayer(who)
if GetPlayer then
if isGuestAccount(getPlayerAccount ( GetPlayer )) then
outputChatBox(GuestError2, player, 255, 0, 0, true)
else
local getAcc = getPlayerAccount ( GetPlayer )
local getPointsPlayer = getAccountData(getAcc, "Points")
local getCashPlayer = getAccountData(getAcc, "Cash")
local getRankPlayer = getAccountData(getAcc, "Rank")
local getWinPlayer = getAccountData(getAcc, "Wins")
local getLosersPlayer = getAccountData(getAcc, "Losers")
outputChatBox("* #FFFFFF" .. PlayerName .. "'s#0fc0fc Stats, Points: " .. getPointsPlayer .. " - Cash: " .. getCashPlayer .. " - Wins: " .. getWinPlayer .. " - Loses: " .. getLosersPlayer .. " - Rank: " .. getRankPlayer, getRootElement(), 255, 255, 255, true)
--outputChatBox("* #FFFFFF" .. PlayerName .. "'s#0fc0fc Stats, Points: " .. getPointsPlayer .. " - Cash: " .. getCashPlayer .. " - Wins: " .. getWinPlayer, getRootElement(), 255, 255, 255, true)
end
end
else
if not isGuestAccount(getPlayerAccount ( source ) ) then
local getAcc = getPlayerAccount ( source )
local getPointsPlayer = getAccountData(getAcc, "Points")
local getCashPlayer = getAccountData(getAcc, "Cash")
local getRankPlayer = getAccountData(getAcc, "Rank")
local getWinPlayer = getAccountData(getAcc, "Wins")
local getLosersPlayer = getAccountData(getAcc, "Losers")
outputChatBox("* #FFFFFF" .. getPlayerName(source) .. "'s#0fc0fc Stats, Points: " .. getPointsPlayer .. " - Cash: " .. getCashPlayer .. " - Wins: " .. getWinPlayer .. " - Loses: " .. getLosersPlayer .. " - Rank: " .. getRankPlayer, getRootElement(), 255, 255, 255, true)
else
outputChatBox(GuestError, source, 255, 0, 0, true)
end
end
end
addCommandHandler("st",Stats)
Alles anzeigen