Jump to content

Help, getAccountData


.:HyPeX:.

Recommended Posts

Im getting return "true", when there's no reason specified for that...

client:

  
function RadioButtonClick() 
local cash = triggerServerEvent("getAccData", getLocalPlayer(), "cash") 
local row, column = guiGridListGetSelectedItem ( RadioGrid ) 
local name = guiGridListGetItemText( RadioGrid, row, 1 ) 
outputChatBox(cash) 
for i, v in ipairs(Wheels) do 
if tostring(v.upgrade) == tostring(name) then 
if cash >= v.price then 
local cash = cash - v.price 
triggerServerEvent("setAccData", getLocalPlayer(), "cash", cash) 
outputChatBox("#00aaff[WheelPanel]: Wheels Bought!", 255,255,255,true) 
v.price = "Bought!" 
else 
outputChatBox("#00aaff[WheelPanel]: You dont have enought money!", 255,255,255,true) 
end 
end 
end 
end 
  

 

server:

  
function getAccData(data) 
outputChatBox("Recived player: ".. getPlayerName(source), getRootElement(), 255,255,255,true) 
outputChatBox("Recived data: ".. data, getRootElement(), 255,255,255,true) 
local acc = getPlayerAccount(source) 
local data = getAccountData(acc, data) 
return data 
end 
addEvent("getAccData", true) 
addEventHandler("getAccData", getRootElement(), getAccData 

Link to comment
"Wheels" isn't defined. I don't know why you're looping that.

Can you please post the exact debug?

There's no error, im reciving true as a return, Due to triggerClientEvent has no return part, it is returning true becouse it was successful, i need a way to take it back to client-side.

About the wheels thing:

  
Wheels = 
    { 
        { name = "Big Ray Wheel", price = "25000", upgrade = 1074 }, 
        { name = "Black Badass", price = "25000", upgrade = 1076 }, 
        { name = "Black Style Wheels", price = "25000", upgrade = 1085 }, 
        { name = "Common Badass", price = "25000", upgrade = 1098 }, 
        { name = "NFS Wheel 1", price = "25000", upgrade = 1075 }, 
        { name = "Cool Wheel 1", price = "25000", upgrade = 1077 }, 
        { name = "Styled Black", price = "25000", upgrade = 1096 }, 
        { name = "Cool Grey", price = "25000", upgrade = 1081}, 
        { name = "NFS Wheel 2", price = "25000", upgrade = 1080 }, 
        { name = "Organe", price = "25000", upgrade = 1073 }, 
        { name = "Cool Wheel 2", price = "25000", upgrade = 1078 }, 
        { name = "Golden Style", price = "25000", upgrade =  1025 }, 
        { name = "Really White Wheels", price = "25000", upgrade = 1082 }, 
        { name = "Cool Wheel 3", price = "25000", upgrade = 1079 }, 
        { name = "Cool Rays", price = "25000", upgrade = 1083 }, 
        { name = "NFS Wheel 3", price = "25000", upgrade = 1097 }, 
        { name = "4x4", price = "25000", upgrade = 1084 } 
    } 

Link to comment
"Wheels" isn't defined. I don't know why you're looping that.

Can you please post the exact debug?

There's no error, im reciving true as a return

Are you sure?

  
addEventHandler("getAccData", getRootElement(), getAccData 

There is a missing bracket ")".

Link to comment
  
function getAccData(data) 
local acc = getPlayerAccount(source) 
if not ( isGuestAccount(acc) ) then 
local data = getAccountData(acc, data) 
return data 
outputChatBox("Recived player: ".. getPlayerName(source), getRootElement(), 255,255,255,true) 
outputChatBox("Recived data: ".. data, getRootElement(), 255,255,255,true) 
else 
return false 
end 
end 
addEvent("getAccData", true) 
addEventHandler("getAccData", getRootElement(), getAccData) 

Link to comment
  • Moderators
  
function getAccData(data) 
local acc = getPlayerAccount(source) 
if not ( isGuestAccount(acc) ) then 
local data = getAccountData(acc, data) 
return data 
outputChatBox("Recived player: ".. getPlayerName(source), getRootElement(), 255,255,255,true) 
outputChatBox("Recived data: ".. data, getRootElement(), 255,255,255,true) 
else 
return false 
end 
end 
addEvent("getAccData", true) 
addEventHandler("getAccData", getRootElement(), getAccData) 

What's that ? Is it supposed to be the solution you made with him through skype ? If yes, then nice code ! (ironic) You are doing two outputs after a return statement. Even if that function is working as expected.

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