Jump to content

عملة ماليه


Recommended Posts

مثلن لما يضغط على زر يعطيه العمليه الذهبيه وتنحفظ مثل الفلوس

بسم الله نبدأ الشرح

--Client

addEventHandler("onClientGUIClick",root,function() 
if source == button then 
setElementData(localPlayer, "Gold", getElementData(localPlayer, "Gold") + 10) 
end 
end) -- الحين يعطيني 10 ذهب طيب لو طلعت ودخلت الذهب يروح  نسوي اكونت داتا نحفظها 
  

--Server

addEventHandler('onPlayerQuit',root, 
 function (   ) 
  local vAcc = getPlayerAccount(source) 
  if not vAcc or isGuestAccount (vAcc) then return end 
  setAccountData(vAcc,'Gold',getElementData(source,"Gold")) 
   end 
 ) 
      
addEventHandler('onPlayerLogin',root, 
 function(_,acc) 
    local v_Data = getAccountData(acc,'Gold') 
    if ( v_Data ) then 
    setElementData(source, "Gold",getAccountData(acc,'Gold')) 
        end 
    end 
) -- هنا سوينا حفظ للذهب 
  

انشاء الله تفهم بالنسبة لكيف تعرف عدد ذهبك

  
howmany = getElementData(localPlayer,"Gold") 
dxDrawText(howmany, -- باقي الارقمنتات ) 
-- هنا تحذف اول ارقمنت الي هو سترنق الكلام وتحط بداله howmany 
  
  

اتمني اكود افدتك

Link to comment
مشكووور بس لو بسوي بمود ثاني يتحقق من فلوسه الذهب كيف تصير؟

--Server

  
addCommandHandler("HowMany", 
function(p) 
if getElementData(p,"Gold") == 3 then 
outputChatBox("ذهبك 3 " ,p) 
end 
end) 
  
Link to comment

executeSQLQuery( ' CREATE TABLE IF NOT EXISTS `TablSave` (Serial, Gold) ' ) 
  
function onSave( )  
local checkData = executeSQLQuery( ' SELECT * FROM `TablSave` WHERE Serial = ? ', getPlayerSerial(source) ) 
local Gold = getElementData(source,'Gold') 
    if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData ) then 
        executeSQLQuery( ' INSERT INTO `TablSave` (Serial, Gold) VALUES(?, ?) ', getPlayerSerial(source),Gold) 
else  
    local Gold = getElementData(source,'Gold') 
        executeSQLQuery( ' UPDATE`TablSave` SET Serial = ?, Gold = ?', getPlayerSerial(source), Gold ) 
    end 
end 
addEventHandler('onPlayerQuit',getRootElement(),onSave) 
addEventHandler('onPlayerLogout',getRootElement(),onSave) 
  
addEventHandler( 'onPlayerLogin', root, 
function(   ) 
local Save = executeSQLQuery( ' SELECT * FROM `TablSave` WHERE Serial = ? ', getPlayerSerial(source) ) 
    if ( type ( Save ) == 'table' and #Save == 0 or not Save ) then return end 
        setElementData(source,'Gold',Save[1]['Gold']) 
end ) 

اسستخدمهه للحفظ + لو في غلط يا شباب كلموني

للشروطط

if ( getElementData(Element,'Gold') == 1 ) then 

Element = نوع الامنت

مثل

localPlayer - Client Sode

source - Server Side

وتقدر تستخدمه في

Vehicle - Ped - Weapon - Resource - Player

Link to comment

تفضل سويت لك نظـام كأمــل ..

Client Side :

LocalPlayer = getLocalPlayer ( ) 
  
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
TheLabel = guiCreateLabel(8, 363, 206, 25, "Your Gold : ", false) 
guiSetFont(TheLabel, "default-bold-small")  
setTimer ( function ( ) 
triggerServerEvent("OnGetGold",localPlayer) 
end,1000,0)    
end 
) 
  
addEventHandler("onClientRender",root, 
function ( ) 
if ( guiGetVisible ( TheLabel ) ) then  
local TheData = getElementData ( LocalPlayer , "TheGold" )  
if ( TheData ) then  
guiSetText ( TheLabel , "Your Gold : "..TheData ) 
end 
end 
end 
) 
  
  

Server Side :

Sqlite = executeSQLQuery 
DefaultGold = 0 
Sqlite("CREATE TABLE IF NOT EXISTS GoldSystem (TheSerial,TheGold)") 
  
addEventHandler("onResourceStart",resourceRoot, 
function ( ) 
local ThePlayers = getElementsByType("player") 
for Index,Values in ipairs ( ThePlayers ) do  
local Default = Sqlite("SELECT * FROM GoldSystem WHERE TheSerial=?",tostring(getPlayerSerial(Values))) 
if ( Default and type ( Default ) == "table" and #Default ~= 0 ) then  
setElementData ( Values , "TheGold" , Default[1]["TheGold"] ) 
else 
setElementData ( Values , "TheGold" , tonumber ( DefaultGold ) ) 
end 
end 
end 
) 
  
addEventHandler("onPlayerJoin",root, 
function ( ) 
local Default = Sqlite("SELECT * FROM GoldSystem WHERE TheSerial=?",tostring(getPlayerSerial(source))) 
if ( Default and type ( Default ) == "table" and #Default ~= 0 ) then  
setElementData ( source , "TheGold" , Default[1]["TheGold"] ) 
else 
setElementData ( source , "TheGold" , tonumber ( DefaultGold ) ) 
end 
end 
) 
  
addEvent("OnGetGold",true) 
addEventHandler("OnGetGold",root, 
function ( ) 
local Default = Sqlite("SELECT * FROM GoldSystem WHERE TheSerial=?",tostring(getPlayerSerial(client))) 
if ( Default and type ( Default ) == "table" and #Default ~= 0 ) then  
setElementData ( client , "TheGold" , Default[1]["TheGold"] ) 
else 
setElementData ( client , "TheGold" , tonumber ( DefaultGold ) ) 
end 
end 
) 
  
  
function getPlayerGold ( player ) 
local Default = Sqlite("SELECT * FROM GoldSystem WHERE TheSerial=?",tostring(getPlayerSerial(player))) 
if ( Default and type ( Default ) == "table" and #Default ~= 0 ) then  
return Default[1]["TheGold"] 
else 
return false 
end 
end 
  
function setPlayerGold ( player , gold ) 
if ( type ( gold ) ~= "number" ) then  
return false 
end 
local Default = Sqlite("SELECT * FROM GoldSystem WHERE TheSerial=?",tostring(getPlayerSerial(player))) 
if ( Default and type ( Default ) == "table" and #Default ~= 0 ) then  
Sqlite("UPDATE GoldSystem SET TheGold=? WHERE TheSerial=?",Default[1]["TheGold"]+gold,tostring(getPlayerSerial(player))) 
setElementData ( player , "TheGold" , Default[1]["TheGold"] ) 
else 
Sqlite("INSERT INTO GoldSystem (TheSerial,TheGold) VALUES (?,?)",tostring(getPlayerSerial(player)),DefaultGold) 
setElementData ( player , "TheGold" , DefaultGold ) 
end 
end 
  
  
  
addCommandHandler("Gold",  
function ( player , command , text ) 
if ( player and text ) then  
if ( text == "info" ) then  
local Gold = getPlayerGold ( player ) 
outputChatBox("* Your Gold : "..Gold , player , 255 , 255 , 0 , true ) 
end 
if ( text == "giveing" ) then  
setPlayerGold ( player , 1 ) 
end 
end 
end 
) 
  

ملأحظات :

لو تبي تعطي نفسك ذهب اكتب في اف 8 Gold giveing

لو تبي تجيب كم ذهب عندك اكتب في اف 8 Gold info

Link to comment
ما ضبط ما يعطي

بسئلك ما ينفع اريح راسي واسوي مثل نظام فلوس اللعبه بالضبط لكن لخيهم للجولد يعني انسخ الاكواد الاصليه ينفع؟؟

م فهمت عليك

Link to comment
صح لما تحمل اللعبه يجي نظام الفلوس العمله الخضراء ينفع انسخ اكوادها والصقها لكن احولها لجولد وكذا يصير عملتين ونفس الوقت ينحفظون

وكيف تجيب اكوادها ذي ؟ :|

Link to comment

addEventHandler("onClientRender",root, 
function ( ) 
if ( guiGetVisible ( TheLabel ) ) then 
local TheData = getElementData ( LocalPlayer , "TheGold" ) 
if ( TheData ) then 
guiSetText ( TheLabel , "Your Gold : "..TheData ) 
end 
end 
end 
) 
  

ليه حاط دا الشرط

if ( TheData ) then  

؟؟

+ وش دا

LocalPlayer = getLocalPlayer ( ) 

مب لها اي لاززززززززمه

localPlayer 

وخلاص وتكون وفرت سطر

function ( player , command , text ) 
if ( player and text ) then 

وش سالفة التحققات دا فهمني يمكن استفاد

ض1

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