Seba500PLK Posted August 12, 2014 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
Et-win Posted August 12, 2014 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. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Seba500PLK Posted August 12, 2014 Author 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 )
Et-win Posted August 12, 2014 Posted August 12, 2014 now help with this. Bye. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
xXMADEXx Posted August 12, 2014 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 ) The Ultimate Lua Tutorial! | MTA PHP SDK
Seba500PLK Posted August 12, 2014 Author Posted August 12, 2014 ok, thank you. Then the proof, because now my hosting does not work: /
Max+ Posted August 12, 2014 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 - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
xXMADEXx Posted August 12, 2014 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. The Ultimate Lua Tutorial! | MTA PHP SDK
Max+ Posted August 13, 2014 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 , - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
xXMADEXx Posted August 13, 2014 Posted August 13, 2014 Welcome. The Ultimate Lua Tutorial! | MTA PHP SDK
Et-win Posted August 13, 2014 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. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Seba500PLK Posted August 13, 2014 Author 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
Et-win Posted August 13, 2014 Posted August 13, 2014 First get the player's account, and then do set/getAccountData. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Et-win Posted August 13, 2014 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') ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Seba500PLK Posted August 13, 2014 Author Posted August 13, 2014 i leave and join the sever reset points
Et-win Posted August 13, 2014 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. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
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