Jump to content

طلب تصحيح كود سيرفر وكلنت مهم


Recommended Posts

انا عندي كود سييرفر فيه غلط

اذا اشترى سيارة ومامعاه فلوس تجيه السيارة وانا ابي اذا ما معاك فلوس ماتشتري موتر

ذا الكود سييرفر

  
server 
  
addEvent("goodbuy",true) 
addEventHandler("goodbuy",root, 
 function (car) 
  
        if getElementData ( source, "destroy" ) then 
            destroyElement ( getElementData ( source, "destroy")) 
            end 
        local carName = getVehicleIDFromName(car) 
            local x, y, z = getElementPosition ( source ) 
            Vehicle = createVehicle (carName, x, y, z ) 
            warpPedIntoVehicle ( source, Vehicle) 
         setElementData ( source, "destroy", Vehicle ) 
showCursor (false ) 
  
  end 
) 
  
  
addEvent("give",true)  
  
addEventHandler("give",root,  
  
function() 
local PlayerMoney = getPlayerMoney(source) 
 if ( PlayerMoney >= 50000) then 
  
    takePlayerMoney(source,50000)  
     
     local name = getPlayerName(source) 
  
        outputChatBox ( "#330079" .. name .. "  this player buying car", getRootElement(), 255, 0, 0, true ) 
 showCursor (false ) 
   
      
    else 
  
  
        outputChatBox("You don't have $50000 not buy", source, 255, 0, 0, true) 
end  
  
end  
  
)  

client 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
  
function(button, state, absoluteX, absoluteY) 
  
if ( source ==  buying ) then  
  
  
  
  
triggerServerEvent("give",getLocalPlayer())  
 guiSetVisible(wnd,false) 
showCursor(false)  
end  
 end 
  
  
)  
  
addEventHandler("onClientGUIClick",buying,  
function ()  
local car = guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 ) 
 if car == "" then return outputChatBox("Please Chose Vehicle!", 255,255,0,true) end 
triggerServerEvent("goodbuy",localPlayer,car)  
end,false) 

الكود عارف ان فيه اخطاااااء :lol:

هريسه على قولة تابل

ارجو ساعدوني

Link to comment

اصلا افنت give

مكان موجود بس goodbuy

بس حطيت على افنت goodbuy

سحب فلوس مانفع فسويت افنت ذذ ومازبط وانا ابي مساعده الكود الاصلي

قبل مااحط افنت give

  
addEvent("goodbuy",true) 
addEventHandler("goodbuy",root, 
 function (car) 
local PlayerMoney = getPlayerMoney(source) 
  
 if ( PlayerMoney >= 50000) then 
  
    takePlayerMoney(source,50000)   
        if getElementData ( source, "destroy" ) then 
            destroyElement ( getElementData ( source, "destroy")) 
            end 
        local carName = getVehicleIDFromName(car) 
            local x, y, z = getElementPosition ( source ) 
            Vehicle = createVehicle (carName, x, y, z ) 
            warpPedIntoVehicle ( source, Vehicle) 
         setElementData ( source, "destroy", Vehicle ) 
showCursor (false ) 
  
                    else 
  
  
        outputChatBox("You don't have $50000 not buy", source, 255, 0, 0, true) 
        end  
  end 
) 

ذا الكود الاصلي قبل مااضيف الافنت الثاني

بس ابي يسحب فلوس 50 الف

ويشتري سيارة

اذ مامعه لايشتري سيارة

وشكرا تابل وابو شنب على المرور :D

Link to comment
-- # Client Side ! 
  
addEvent("onHide",true) 
addEventHandler("onHide",root,function() 
guiSetVisible(wnd, false) 
showCursor(false) 
end) 
  
addEventHandler("onClientGUIClick",root, 
function () 
if ( source == buying ) then 
if ( guiGridListGetSelectedItem ( grid ) ~= -1 ) then 
local car = guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 ) 
triggerServerEvent("goodbuy",localPlayer,car) 
else 
outputChatBox("Please Choose Vehicle!", 255,255,0,true) 
end 
end 
end) 

-- # Server Side ! 
  
local veh = {} 
  
addEvent("goodbuy",true) 
addEventHandler("goodbuy",root, 
function (TheName) 
if ( getPlayerMoney(source) >= 50000) then 
takePlayerMoney(source,50000) 
if ( isElement(veh[source] ) then destroyElement(veh[source]) veh[source] = nil end 
local x, y, z = getElementPosition ( source ) 
local id = getVehicleIDFromName(TheName) 
veh[source] = createVehicle (tonumber(id), x + 3, y, z ) 
warpPedIntoVehicle ( source, veh[source]) 
triggerClientEvent(source,"onHide",source) 
else 
outputChatBox("You don't have $50000 To Buy a Car", source, 255, 0, 0, true) 
triggerClientEvent(source,"onHide",source) 
end 
end) 
  
addEventHandler("onPlayerQuit",root,function() 
if ( isElement(veh[source] ) then destroyElement(veh[source]) veh[source] = nil end 
end) 

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