Jump to content

nxFairlywell

Members
  • Posts

    1,849
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by nxFairlywell

  1. اكواد السيرفر حطها اخر شي بملف السيرفر وكذلك اكواد الكلينت

    ماراح تخرب عليك نهائياً

    بس عدل المتغيرات

  2. 39 minutes ago, ايهاب said:

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

    انا ما ابى اتعلم لكن عايز حل المشكلة

    عندى بق فى القيم مود  الحل بتاعة

    ياريت حد يساعدى عايز اما اللاعب يموت النجوم تتمسح واما يخرج من السيرفر النجوم تتمسح

    عارف الكودات المستخدمة لكن مش عارف اعملها

    بس لو حد عملهالى يبقى مشكور لانة  ابيها ضرورى اول بق يطلعلى

    يعني اللاعب خرج كيف تبي تمسح نجومه وهو اصلاً مافيه لاعب

  3. 1 hour ago, KonaaaN200 said:

    ممكن الأكواد لا هنت

     

    Server

    -- Server
    
    addEventHandler("onResourceStart",resourceRoot,
    	function()
    		executeSQLQuery("CREATE TABLE IF NOT EXISTS BAN_LIST (PlayerSerial TEXT,ResponsibleSerial TEXT)");
    	end
    )
    
    function onPlayerBanned(responsible)
    	local player = source;
    	local playerSerial = getPlayerSerial(player);
    	local responsibleSerial = getPlayerSerial(responsible);
    	local SQL = executeSQLQuery("SELECT * FROM BAN_LIST WHERE PlayerSerial=?",playerSerial);
    	if SQL[1] == nil then
    		executeSQLQuery("INSERT INTO BAN_LIST (PlayerSerial,ResponsibleSerial) VALUES(?,?)",playerSerial,responsibleSerial);
    		local SQL = executeSQLQuery("SELECT * FROM BAN_LIST WHERE PlayerSerial=?",playerSerial);
    		if SQL[1] ~= nil and SQL[1].PlayerSerial == playerSerial then
    			triggerClientEvent(player,"onClientPlayerBanned",player,responsible);
    		end
    	else
    		outputChatBox("هذا اللاعب في قائمة الحظر بالفعل !",responsible);
    	end
    end
    
    addEvent("onPlayerBanned",true);
    addEventHandler("onPlayerBanned",root,onPlayerBanned);
    
    addEvent("OnClientStart",true);
    addEventHandler("OnClientStart",root,function()
    	local playerSerial = getPlayerSerial(source);
    	local SQL = executeSQLQuery("SELECT * FROM BAN_LIST WHERE PlayerSerial=?",playerSerial);
    	if SQL[1] == nil then
    		triggerClientEvent(source,"OnClientStart",source);
    	else
    		triggerClientEvent(source,"OnClientStart",source,true);
    	end
    end)

     

     

    Client

    BanPlayer(player): 

    1. player : اللاعب اللي تبي تحظره , طبعاً انت تحدد طريقة اختيار اللاعب انا ماحددت طريقة انا حطيت الفنكشن بس
    -- client
    local key1 = "F2"; -- زر اللوحة الاولى
    local key2 = "F3"; -- زر اللوحة الثانية
    local window1 = var1; -- الى متغير اللوحة الاولى var1 غير
    local window2 = var2; -- الى متغير اللوحة الثانية var2 غير
    
    function OpenFirstWindow()
    	if not guiGetVisible(window1) then
    		guiSetVisible(window1,true);
    		showCursor(true);
    	else
    		guiSetVisible(window1,false);
    		showCursor(false);
    	end 
    end
    
    function OpenSecondWindow()
    	if not guiGetVisible(window2) then
    		guiSetVisible(window2,true);
    		showCursor(true);
    	else
    		guiSetVisible(window2,false);
    		showCursor(false);
    	end 
    end
    
    addEventHandler("onClientResourceStart",resourceRoot,function()
    	triggerServerEvent("OnClientStart",localPlayer);
    end);
    function BanPlayer(player)
    	if player and isElement(player) and getElementType(player)=="player" then
    		local responsible = localPlayer;
    		triggerServerEvent("onPlayerBanned",player,responsible);
    		return true;
    	end
    	return false;
    end
    
    function onClientPlayerBanned(responsible)
    	outputChatBox("لقد تم حظرك من قبل "..getPlayerName(responsible):gsub("#%x%x%x%x%x%x",""),244,14,14);
    	unbindKey("زر اللوحة المحظورة","down",OpenFirstWindow);
    	bindKey("زر اللوحة الثانية","down",OpenSecondWindow);
    	guiSetVisible(window1,false);
    	showCursor(false);
    end
    
    addEvent("onClientPlayerBanned",true);
    addEventHandler("onClientPlayerBanned",root,onClientPlayerBanned);
    
    addEvent("OnClientStart",true);
    addEventHandler("OnClientStart",root,function(isBanned)
    	if not isBanned then
    		bindKey(key1,"down",OpenFirstWindow);
    	else
    		bindKey(key2,"down",OpenSecondWindow);
    	end
    end)
  4. Cylinder1 = createMarker(3139.8, -3254.3, 123.22222, "cylinder", 1.0, 0, 255, 255, 255)
    
    function TEST(playerhit)
    	if source == Cylinder1 then
    		if playerhit and getElementType(playerhit)=="player" then
    			outputChatBox("U hit marker", root)
    		end
    	end
    end
    
    addEventHandler("onMarkerHit", root, TEST)

     

  5. In second part add an if-statement

    addEventHandler("onClientRender", getRootElement(),
    function ()
    	for _, player in ipairs(getElementsByType("player")) do
    		if getElementData(player, "Room") then
            	   if getElementDimension(player)==getElementDimension(localPlayer) then
    				 dxDrawTextOnElement(player, getPlayerName(player), 0.9, 70, 255, 255, 255, 255, 1.5, "sans")
                       end
    		end
    	end
    end)

     

  6. 27 minutes ago, areoslasher said:

    Wow man that was extremely helpful, I will go through the code and try to let it sink in.. I really appreciate taking your time, thank you very much!

    -hope you don't mind if I pm you if I don't understand something? If that's not okay just let me know, I wouldn't want to bother you. You helped me more than I expected!

    Np, You're welcome ?

  7. You should use 'executeSQLQuery' in the beginning. This will be fine for your start ?

    Let's see how it works..

    In the following example, We have 4 values to save them in the Database.

    1. the user's account name
    2. the user's money
    3. the user's car ID
    4. the user's custom points

    Now we going to create a table in local Database and it's name will be "aeroTable" :

    addEventHandler("onResourceStart",getThisResource(),
    	function()
    		executeSQLQuery("CREATE TABLE IF NOT EXIST `aeroTable`")
    	end
    )

    Done! We have created an aeroTable. But, We haven't created the columns that we need to save the values in them!!

    Let's make some columns :

    addEventHandler("onResourceStart",getThisResource(),
    	function()
    		executeSQLQuery("CREATE TABLE IF NOT EXIST `aeroTable` (account_name TEXT, money TEXT, carID TEXT, customPoints TEXT)")
    	end
    )

    Okay, Now we have created the columns, and the names have been as we named them before.

    Now we going to save the values in this columns ..

    function SaveValues(accountName,money,carID,customPoints)
    	if accountName and type(accountName)=="string" and getAccount(accountName) then
    		local SQL = executeSQLQuery("SELECT * FROM aeroTable WHERE account_name=?",accountName);
    		if SQL and type(SQL)=="table" and #SQL > 0 then
    			executeSQLQuery("UPDATE aeroTable SET money=?, carID=?, customPoints=?",money,carID,customPoints);
    			print(accountName.." In Database updated!");
    		else -- There are no values, that means the account_name column is empty and this account we sent it has no values in the Database, So we have to set the values.
    			executeSQLQuery("INSERT INTO aeroTable(account_name,money,carID,customPoints) VALUES(?,?,?,?)",accountName,money,carID,customPoints);
    			print(accountName.." Has been successfully added to the aeroTable");
    		end
    		return true;
    	end
    	return false;
    end

    And we going to add a command for testing :

    addCommandHandler("SaveMe",
    	function(player,cmd)
    		if not isGuestAccount(getPlayerAccount(player)) then
    			local accountName = getAccountName(getPlayerAccount(player));
    			if accountName then
    				local money = tostring ( getPlayerMoney(player) );
    				local carID;
    				if getPedOccupiedVehicle(player) then
    					carID = tostring( getElementModel(getPedOccupiedVehicle(player)) );
    				else
    					carID = "N/A";
    				end
    				local customPoints = getElementData(player,"points") and tostring(getElementData(player,"points")) or "0";
    				SaveValues(accountName,money,carID,customPoints);
    			end
    		end
    	end
    )

    Finally, We going to show the values for that user who just entered this command "ShowMe"

    addCommandHandler("ShowMe",
    	function(player,cmd)
    		if not isGuestAccount(getPlayerAccount(player)) then
    			local accountName = getAccountName(getPlayerAccount(player));
    			if accountName then
    				local SQL = executeSQLQuery("SELECT * FROM aeroTable WHERE account_name=?",accountName);
    				if SQL and type(SQL)=="table" and #SQL > 0 then
    					outputChatBox(SQL[1].account_name,player);
    					outputChatBox(SQL[1].money,player);
    					outputChatBox(SQL[1].carID,player);
    					outputChatBox(SQL[1].customPoints,player);
    				else
    					outputChatBox("Use SaveMe to save your information",player);
    				end
    			end
    		end
    	end
    )

    Hope that was helpfully ? Post your issues here if you don't understand. 

     

    Full code :

    addEventHandler("onResourceStart",resourceRoot,
    	function()
    		executeSQLQuery("CREATE TABLE IF NOT EXISTS aeroTable (account_name TEXT, money TEXT, carID TEXT, customPoints TEXT)")
    	end
    )
    
    function SaveValues(accountName,money,carID,customPoints)
    	if accountName and type(accountName)=="string" and getAccount(accountName) then
    		local SQL = executeSQLQuery("SELECT * FROM aeroTable WHERE account_name=?",accountName);
    		if SQL and type(SQL)=="table" and #SQL > 0 then
    			executeSQLQuery("UPDATE aeroTable SET money=?, carID=?, customPoints=?",money,carID,customPoints);
    			print(accountName.." In Database updated!");
    		else -- There are no values, that means the account_name column is empty and this account we sent it has no values in the Database, So we have to set the values.
    			executeSQLQuery("INSERT INTO aeroTable(account_name,money,carID,customPoints) VALUES(?,?,?,?)",accountName,money,carID,customPoints);
    			print(accountName.." Has been successfully added to the aeroTable");
    		end
    		return true;
    	end
    	return false;
    end
    
    addCommandHandler("SaveMe",
    	function(player,cmd)
    		if not isGuestAccount(getPlayerAccount(player)) then
    			local accountName = getAccountName(getPlayerAccount(player));
    			if accountName then
    				local money = tostring ( getPlayerMoney(player) );
    				local carID;
    				if getPedOccupiedVehicle(player) then
    					carID = tostring( getElementModel(getPedOccupiedVehicle(player)) );
    				else
    					carID = "N/A";
    				end
    				local customPoints = getElementData(player,"points") and tostring(getElementData(player,"points")) or "0";
    				SaveValues(accountName,money,carID,customPoints);
    			end
    		end
    	end
    )
    
    addCommandHandler("ShowMe",
    	function(player,cmd)
    		if not isGuestAccount(getPlayerAccount(player)) then
    			local accountName = getAccountName(getPlayerAccount(player));
    			if accountName then
    				local SQL = executeSQLQuery("SELECT * FROM aeroTable WHERE account_name=?",accountName);
    				if SQL and type(SQL)=="table" and #SQL > 0 then
    					outputChatBox(SQL[1].account_name,player);
    					outputChatBox(SQL[1].money,player);
    					outputChatBox(SQL[1].carID,player);
    					outputChatBox(SQL[1].customPoints,player);
    				else
    					outputChatBox("Use SaveMe to save your information",player);
    				end
    			end
    		end
    	end
    )

     

    • Thanks 1
  8. "Put a timer after tapping a command"

    -- command, id of car, txt of car, replace texture
    
    local cmdTime = 10000
    local skins = {
    	{"test", 411, "bopp", "test.png"},
    }
    
    local PlayerTappedCommand = {};
    
    function getSkinByCMD(cmd)
    	if cmd and type(cmd)=="string" then
    		local skin = {};
    		for i = 1, #skins do
    			if skins[i][1]==cmd then
    				skin[1]=cmd;skin[2]=skins[2];skin[3]=skins[3];skin[4]=skins[4];
    				return skin;
    			end
    		end
    		return {};
    	end 
    	return false;
    end
    
    function DoSomething(plr, skin)
    	if getPedOccupiedVehicle(plr) and getElementModel(getPedOccupiedVehicle(plr)) == skin[2] then
    		triggerClientEvent(root, "onNalozPJ", root, getPedOccupiedVehicle(plr), skin[2], skin[3], "txt/"..skin[4])
    		PlayerTappedCommand[plr] = false;
    	end
    end
    
    function CommandFunc(player,cmd)
    	if PlayerTappedCommand[player] then outputChatBox("you used the command before!",player) return false; end
    	local skin = getSkinByCMD(cmd);
    	if skin and type(skin)=="table" and #skin>0 then
    		PlayerTappedCommand[player] = true;
    		local Timer = setTimer(DoSomething, cmdTime, 1, player, skin);
    	end
    	outputConsole ("Wrong command or skin = {empty}",player);
    	return false;
    end
    
    for i = 1, #skins do
    	addCommandHandler(skins[i][1],CommandFunc)
    end

     

  9. Local player is actually the client!

    So server side script hasn't local player because the script is server side :)

    you should use this in client side

    triggerServerEvent("EventName",localPlayer) -- localPlayer = source of the event in server side

    and you can receive your event from server side like this :

    addEvent("EventName",true)
    addEventHandler("EventName",root,
      function()
        local localPlayer = source; -- source is that player you put in the triggerServerEvent
        -- now you have the localPlayer in the server
      end
    )

    also, there are another methods you can use, but this is a simple example.

     

    Note :

    When you need to use the localPlayer in server side, you will be automatically must be using the triggerServerEvent function.

    So in the logic you have to trigger an event

     

    When you want to use localPlayer?

  10. 3 minutes ago, Laith. said:

    اه تقعد تتغير كل شوي

    path1 - path2 - path3 - path4

    هي مسارات الصورة الجديده , تكتبها بين علامتين تنصيص

    "path1.png" - "path2.png" ...etc

    image1 -2-3-4

    (StaticImage)هي متغيرات الصور اللي انت مسويها 

    local Time = 10; -- الوقت بين التغييرات بالثواني
    
    function ChangeImage()
    	guiStaticImageLoadImage(image1,path1); -- 1
    	guiStaticImageLoadImage(image2,path2); -- 2
    	guiStaticImageLoadImage(image3,path3); -- 3
    	guiStaticImageLoadImage(image4,path4); -- 4
    	-- image1 = StaticImage1
    	-- وكذلك مع بقية الصور
    	-- path1 = مسار الصورة الاولى الجديد
    	-- وكذلك مع البقية
    	return true
    end
    
    setTimer(ChangeImages, Time*1000, 0)

    اذا تبي تغيير الصور عشوائي يعني عندك صور كثيره وتبي يختار عشوائي حط ذا الكود

    local Time = 40; -- الوقت بين التغييرات بالثواني
    
    local path = {
    	"path.png",
    	"path1.png",
    	"path2.png",
    };
    
    function ChangeImage()
    	guiStaticImageLoadImage(image1,path[math.random(1,#path)]); -- 1
    	guiStaticImageLoadImage(image2,path[math.random(1,#path)]); -- 2
    	guiStaticImageLoadImage(image3,path[math.random(1,#path)]); -- 3
    	guiStaticImageLoadImage(image4,path[math.random(1,#path)]); -- 4
    	-- image1 = StaticImage1
    	-- وكذلك مع بقية الصور
    	-- path[math.random(1,#path)] = مسار صورة عشوائي
    	return true
    end
    
    setTimer(ChangeImages, Time*1000, 0)

    عاد انت لازم تعدل عليه وتضيف الاشياء الناقصه مثل متغيرات الصور ومسارات الصور في الجدول

×
×
  • Create New...