Seba500PLK Posted August 12, 2014 Share Posted August 12, 2014 (edited) Hello, whether it is possible to create a second currency to the server?, the second currency wants to use to buy vip If possible ask for any some code Edited August 12, 2014 by Guest Link to comment
Et-win Posted August 12, 2014 Share Posted August 12, 2014 I'm sure you can create your own system and use database functions. And then with exports functions you can easily save and get money. Maybe there is even an easier way. Link to comment
Seba500PLK Posted August 12, 2014 Author Share Posted August 12, 2014 I found some code, now help with this. He wants to list the screen but does not work. "Twoje PP" does not exist on the screen. Help This is not the whole part of the code --Client function getPlayerPoints (thePlayer) if saveMethod == "accounts" then if not isGuestAccount(getPlayerAccount(thePlayer)) then local account = getPlayerAccount(thePlayer) local points = getAccountData(account, "points_class") return tonumber(points) else outputDebugString("pointsystem_classes - getPlayerPoints (Account is guest! Can't get points!)") end elseif saveMethod == "database" then local serial = getPlayerSerial(thePlayer) local points = executeSQLSelect ( "pointsystem_classes", "points","serial = '" .. serial .. "'") if points then return tonumber(points[1]["points"]) else outputDebugString("pointsystem_classes - getPlayerPoints (Database unknow problem! Can't get points!)") end end end --Server addEventHandler("onClientResourceStart", resourceRoot, function() end ) addEventHandler("onClientRender", root, function() screenWidth, screenHeight = guiGetScreenSize() local cash2 = getPlayerPoints( getLocalPlayer() ) dxDrawText("Twoje PP: #FF0000"..cash2, screenWidth * 0.7 / 2, screenHeight * 0, screenWidth * 0.5 / 2, screenHeight * 0, tocolor(2, 2, 214, 255), 1, "bankgothic", "left", "top", false, false, true, true) --dxDrawText(""..cash, screenWidth * 0.76 / 2, screenHeight * 0.003, screenWidth * 0.5 / 2, screenHeight * 0, tocolor(255, 0, 0, 255), 0.80, "bankgothic", "left", "top", false, false, true, false, false) end ) Link to comment
Seba500PLK Posted August 12, 2014 Author Share Posted August 12, 2014 ??? why. I use google translate Link to comment
Seba500PLK Posted August 12, 2014 Author Share Posted August 12, 2014 I meant if you could help me Link to comment
Seba500PLK Posted August 12, 2014 Author Share Posted August 12, 2014 I'm sorry if you offended Link to comment
Seba500PLK Posted August 12, 2014 Author Share Posted August 12, 2014 Et-win Please help Link to comment
xXMADEXx Posted August 12, 2014 Share Posted August 12, 2014 Stop flooding this topic. Your code could just be something like this: -- Server side Code function getPlayerMoney ( player ) local m = tonumber ( getElementData ( player, "p_money" ) ) if ( not m ) then m = 0 setElementData ( player, "p_money", 0 ) end return m end function setPlayerMoney ( player, money ) return setElementData ( player, "p_money", money ) end function givePlayerMoney ( player, money ) local c = getPlayerMoney ( player ) return setPlayerMoney ( player, c + money ) end -- Client side Code function getPlayerMoney ( ) local m = tonumber ( getElementData ( localPlayer, "p_money" ) ) if ( not m ) then m = 0 setElementData ( localPlayer, "p_money", 0 ) end return m end function setPlayerMoney ( money ) return setElementData ( localPlayer, "p_money", money ) end function givePlayerMoney ( money ) local c = getPlayerMoney ( localPlayer ) return setPlayerMoney ( localPlayer, c + money ) end local sx, sy = guiGetScreenSize ( ) addEventHandler ( "onClientRender", root, function ( ) dxDrawText ( "You currently have $"..tostring ( getPlayerMoney ( ) ), 0, 0, sx, sy, tocolor ( 0, 255, 0, 255 ), 2, "default", "center", "top" ) end ) Link to comment
Seba500PLK Posted August 12, 2014 Author Share Posted August 12, 2014 ok, thank you. Then the proof, because now my hosting does not work: / Link to comment
Max+ Posted August 12, 2014 Share Posted August 12, 2014 Stop flooding this topic.Your code could just be something like this: -- Server side Code function getPlayerMoney ( player ) local m = tonumber ( getElementData ( player, "p_money" ) ) if ( not m ) then m = 0 setElementData ( player, "p_money", 0 ) end return m end function setPlayerMoney ( player, money ) return setElementData ( player, "p_money", money ) end function givePlayerMoney ( player, money ) local c = getPlayerMoney ( player ) return setPlayerMoney ( player, c + money ) end -- Client side Code function getPlayerMoney ( ) local m = tonumber ( getElementData ( localPlayer, "p_money" ) ) if ( not m ) then m = 0 setElementData ( localPlayer, "p_money", 0 ) end return m end function setPlayerMoney ( money ) return setElementData ( localPlayer, "p_money", money ) end function givePlayerMoney ( money ) local c = getPlayerMoney ( localPlayer ) return setPlayerMoney ( localPlayer, c + money ) end local sx, sy = guiGetScreenSize ( ) addEventHandler ( "onClientRender", root, function ( ) dxDrawText ( "You currently have $"..tostring ( getPlayerMoney ( ) ), 0, 0, sx, sy, tocolor ( 0, 255, 0, 255 ), 2, "default", "center", "top" ) end ) you forgot to add localPlayer inside the getPlayerMoney ( ) or just replace it with c Link to comment
xXMADEXx Posted August 12, 2014 Share Posted August 12, 2014 you forgot to add localPlayer inside the getPlayerMoney ( ) or just replace it with c It doesn't need a player argument on the client side, it will only work for the local player. Link to comment
Max+ Posted August 13, 2014 Share Posted August 13, 2014 you forgot to add localPlayer inside the getPlayerMoney ( ) or just replace it with c It doesn't need a player argument on the client side, it will only work for the local player. Oh Right i saw the server argument , Link to comment
Seba500PLK Posted August 13, 2014 Author Share Posted August 13, 2014 ok work, thanks Link to comment
Seba500PLK Posted August 13, 2014 Author Share Posted August 13, 2014 restart server, points reset Link to comment
Seba500PLK Posted August 13, 2014 Author Share Posted August 13, 2014 if someone can someone help me? Link to comment
Et-win Posted August 13, 2014 Share Posted August 13, 2014 Instead of 'set/getElementData' use 'set/getAccountData', so it saves. But the player has to be logged in by then. (This all is server-side. Link to comment
Seba500PLK Posted August 13, 2014 Author Share Posted August 13, 2014 --Server function getPlayerMoney ( player ) local m = tonumber ( getAccountData ( player, "p_money" ) ) if ( not m ) then m = 0 setAccountData ( player, "p_money", 0 ) end return m end function setPlayerMoney ( player, money ) return setAccountData ( player, "p_money", money ) end function givePlayerMoney ( player, money ) local c = getPlayerMoney ( player ) return setPlayerMoney ( player, c + money ) end dont work, no saved Link to comment
Et-win Posted August 13, 2014 Share Posted August 13, 2014 First get the player's account, and then do set/getAccountData. Link to comment
Seba500PLK Posted August 13, 2014 Author Share Posted August 13, 2014 I'm sorry but I can not understand Link to comment
Et-win Posted August 13, 2014 Share Posted August 13, 2014 --Server function getPlayerMoney ( player ) local m = false local gPlayerAccount = getPlayerAccount(player) if (gPlayerAccount ~= false) and (isGuestAccount(gPlayerAccount) == false) then m = tonumber ( getAccountData ( gPlayerAccount, "p_money" ) ) if ( not m ) then m = 0 setAccountData ( player, "p_money", 0 ) end end return m end I did the first one, you can do the rest (getPlayerAccount(player)) (If the player was not logged in, then it returns 'false') Link to comment
Seba500PLK Posted August 13, 2014 Author Share Posted August 13, 2014 i leave and join the sever reset points Link to comment
Et-win Posted August 13, 2014 Share Posted August 13, 2014 Did you do the other functions too? And you need to add event 'onPlayerLogin' and then give the player her/his money. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now