Jump to content

تشتغل الوضيفه من ثاني امر


3ssol

Recommended Posts

Slam 3lekm

شباب ابي اسوي كذا

addCommandHandler

لما تكتب الامر مرتين تشتغل وضيفه من عندي اسويها

فهمتوني؟

يعني اكتبها مره وحده مايصير شي

تكتبها مره ثانيه تصير وضيفه انا مسويها

وشكرا

Link to comment
local count = 0 
  
addCommandHandler("test", 
    function (player) 
        if count <= 3  then 
            givePlayerMoney(player,100) -- your function 
            count = 0 
        else 
            count = count +1 
        end 
    end 
) 
  
  

Link to comment

^ طريقتك صحيحة ولكن بما انها بـ جانب السيرفر

راح يتعارض مع اللاعبين

count فـ مثلاً انا كتبت الكلمة رايح يزيد واحد لـ المتغير

count وانت كتبت الكلمة راح يزيد واحد لـ المتغير

فـ الأفضل استخدام الجدول بـ جانب السيرفر

Link to comment
num = 4 -- max count 
count = {} 
  
addCommandHandler("test", 
    function (player) 
        if count[player] == num then 
            givePlayerMoney(player,100) -- your function 
            count[player] = 0 
        else 
            count[player] = count[player] + 1 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin",root, 
    function () 
        count[source] = 0 
    end 
) 
  

Edited by Guest
Link to comment

@ |Mr|-Talal07-| : عندك خطأ في سطر 17

@ 3ssol : جرب ذا الكود

local num = 4 -- max count 
local count = { } 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function( ) 
        for _,player in ipairs( getElementsByType( "player" ) ) do 
            count[player] = 0 
        end 
    end 
) 
  
addEventHandler( "onPlayerJoin", root, 
    function( ) 
        count[source] = 0 
    end 
) 
  
addCommandHandler( "test", 
    function( player ) 
        count[player] = count[player] + 1 
        if count[player] >= num then 
            givePlayerMoney( player, 100 ) -- your function 
            count[player] = 0 
        end 
    end 
) 

Link to comment
@ |Mr|-Talal07-| : عندك خطأ في سطر 17

@ 3ssol : جرب ذا الكود

local num = 4 -- max count 
local count = { } 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function( ) 
        for _,player in ipairs( getElementsByType( "player" ) ) do 
            count[player] = 0 
        end 
    end 
) 
  
addEventHandler( "onPlayerJoin", root, 
    function( ) 
        count[source] = 0 
    end 
) 
  
addCommandHandler( "test", 
    function( player ) 
        count[player] = count[player] + 1 
        if count[player] >= num then 
            givePlayerMoney( player, 100 ) -- your function 
            count[player] = 0 
        end 
    end 
) 

والله ما ادري وش يبي فيه

اكتب كومند 4 مرات وش ابي به ضض

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