Jump to content

Jaydan

Members
  • Posts

    32
  • Joined

  • Last visited

Posts posted by Jaydan

  1. You could use the if operator to check the weapon:

      
    addEvent( "headboom", true ) 
    function Zheadhit ( ped,attacker, weapon, bodypart) 
     if weapon == WEAPONHERE or weapon == WEAPONHERE then 
        if (getElementData (ped, "zombie") == true) then 
            killPed ( ped, attacker, weapon, bodypart ) 
            setPedHeadless  ( ped, true ) 
        end 
     end 
    end 
    addEventHandler( "headboom", getRootElement(), Zheadhit ) 
      
    

    But it is cleaner to use a table and use the if operator on the table like below:

      
    local weaponsBoom = { 
       [WEAPONHERE] = true, 
    } 
      
    addEvent( "headboom", true ) 
    function Zheadhit ( ped,attacker, weapon, bodypart) 
     if weaponsBoom[weapon] then 
        if (getElementData (ped, "zombie") == true) then 
            killPed ( ped, attacker, weapon, bodypart ) 
            setPedHeadless  ( ped, true ) 
        end 
     end 
    end 
    addEventHandler( "headboom", getRootElement(), Zheadhit ) 
      
    

  2. Well, it would make your script more readable but every time you create a variable it stores it in the memory so technically speaking I guess it would be more efficient if you didn't assign a variable to it. Either way the performance isn't going to increase/decrease greatly so do whatever you prefer :P

  3.   
    function redirectOpenPanel(source) 
        triggerClientEvent(source, "openPanel", source) 
    end 
      
    

    Without putting source in the parameters how is it going to know what 'source' is?

    You also forgot to put source as the first parameter in the triggerClientEvent function, without doing that it would send it to every client.

    Also make sure your meta.xml file is correct, if you aren't sure post it below.

  4. One more upload again from A-TEAM!

    THANKS FOR 100+ DOWNLOADS!

    Now this is a car locker!

    Exported functions:

    bool isVehicleLocked( element vehicle ) 
    

    what does this do: Checks if a vehicle is locked

    returned value: if yes returns true else returns false ( it also returns false if there were invalid arguements! Be carefull!)

    vehicle: A element which is vehicle

    bool setVehicleLocked( element vehicle, bool state, element player) 
    

    what does this do: Sets a vehicle to its locked state!

    vehicle: A element which is vehicle

    state: Can be true or false ( true for locking, false for no locking )

    player: A element who will lock the vehicle and have keys!

    returns: True if it was successfully done else false

    Er? Exported?

    https://wiki.multitheftauto.com/wiki/IsVehicleLocked

    https://wiki.multitheftauto.com/wiki/SetVehicleLocked

  5. GUIEditor = { 
        window = {}, 
        memo = {} 
    } 
    addEventHandler("onClientResourceStart", resourceRoot, 
        function() 
            GUIEditor.window[1] = guiCreateWindow(572, 238, 337, 226, "Cheats And Codes Help Panel", false) 
            guiWindowSetSizable(GUIEditor.window[1], false) 
      
            GUIEditor.memo[1] = guiCreateMemo(9, 24, 318, 192, [[-- Multi Theft Auto Cheats And Codes -- 
      
    Cheat Code Commands: 
      
    /power - Gives you 100 power. 
    /rhino - Creates a tank for you. 
    /givemejetpack - Gives you a jetpack. 
    /givemeweapons - Gives you many weapons. 
    /moneymoneymoney - Gives you 1000000 money. 
    /policecantgetme - Sets your wanted level to 2. 
    /jumpjet - Creates a hydra for you. 
    /toodamnhot - Sets weather to scorching hot. 
    /professionalkiller - Sets your weapon stats to max. 
      
    ]], false, GUIEditor.window[1]) 
            guiMemoSetReadOnly(GUIEditor.memo[1], true)     
        end 
    ) 
      
        bindKey ( "o", "down", 
            function ( ) 
                guiSetVisible ( GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) 
                showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) 
            end 
        ) 
    

    Edit; fixed your typos on the bindKey function.

    GUIEditor_window = {} 
    GUIEditor_memo = {} 
      
    function LoadGui() 
     GUIEditor_window[1] = guiCreateWindow(572, 238, 337, 226, "Cheats And Codes Help Panel", false) 
         
        guiWindowSetSizable(GUIEditor_window[1], false) 
          
        GUIEditor_memo[1] = guiCreateMemo(9, 24, 318, 192, [[-- Multi Theft Auto Cheats And Codes -- 
          
        Cheat Code Commands: 
          
        /power - Gives you 100 power. 
        /rhino - Creates a tank for you. 
        /givemejetpack - Gives you a jetpack. 
        /givemeweapons - Gives you many weapons. 
        /moneymoneymoney - Gives you 1000000 money. 
        /policecantgetme - Sets your wanted level to 2. 
        /jumpjet - Creates a hydra for you. 
        /toodamnhot - Sets weather to scorching hot. 
        /professionalkiller - Sets your weapon stats to max. 
          
        ]] 
        , false, GUIEditor_window[1]) 
                guiMemoSetReadOnly(GUIEditor_memo[1], true)     
    end 
    addEventHandler("onClientResourceStart", resourceRoot, LoadGui) 
          
     function showGui() 
        if (guiGetVisible ( GUIEditor_window[1] )) then 
            guiSetVisible(GUIEditor_window[1], false) 
            showCursor(false) 
        else 
            guiSetVisible(GUIEditor_window[1], true) 
            showCursor(true) 
        end 
     end 
     addCommandHandler("cheatcodeshelp", showGui) 
    

  6. hmm i have getting this error now
    [2014-10-01 18:23:17] WARNING: drift\Driftdatabase.lua:1: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] 
    [2014-10-01 18:23:17] WARNING: drift\Driftdatabase.lua:1: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] 
    [2014-10-01 18:23:17] ERROR: drift\Driftdatabase.lua:14: attempt to concatenate local 'accountname' (a boolean value) 
    

    here is the script

      
    

    You need an event, how else is it supposed to get the player lol.

    https://wiki.multitheftauto.com/wiki/Se ... ing_Events

    so say you want to make it sync with the mysql database when a player joins, you' do

      
    handler = mysql_connect("localhost", "root", "", "arizonadrift") 
      
    function playerJoined() 
      local accountname = getPlayerAccount( getPlayerAccount( source ) ) 
      local driftpoints = driftpoints 
      
      
      
        local query = dbQuery ( database, "SELECT * FROM driftpoints WHERE accountname = '" .. accountname .. "' ") 
        local result = dbPoll ( query, -1 ) 
        
       local points = result[1]["points"] 
        
        mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname  .. "' ") 
    end 
    addEventHandler ( "onPlayerJoin", root, playerJoined ) 
      
      
    

  7. hahaha ye first time i make this kinda fail lel never had it before xD

    but if i wanne take the drift score from internal.db how can i do that?

    You'd use dbPoll and dbQuery

      
        local query = dbQuery ( housedb, "SELECT * FROM drift_points WHERE accountname = ''" .. accountherelol .. "" )  
        local result = dbPoll ( query, -1 )  
         
       local points = result[1]["points"] 
      
    

  8. Hi, how to add cottage? command (sorry for bad english)

    /addhouse = a nill valute :(

    This isn't a finished resource, there would be no point in downloading this.

    However, I managed to fix the command.

  9. local accountname = getAccountName( getPlayerAccount( player ) ) 
    local driftpoints = driftpoints 
      
    local handler = mysql_connect("localhost", "root", "kolpol55", "arizonadrift") 
      
    function aaa() 
        dbQuery( myCallback, connection, "SELECT * FROM driftpoints" ) 
    end 
      
    function myCallback(qh) 
        local result = dbPoll( qh, 0 )   -- Timeout doesn't matter here because the result will always be ready 
    end 
      
    mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname  .. "' ") 
    

    thats what i have now

    but its for now just testing

    local driftpoints = driftpoints 
    

    erm, you need to set that something.

    so you are trying to get driftpoints from internal.db?

    and about the error, could you post your meta.xml as well?

  10. https://forum.multitheftauto.com/viewtopic.php?t=42067&f=148

    Read that, next you would want to make a table with the following columns:

    accountname, drift points

    then you'd do something like

      
    local handler = mysql_connect("localhost", "root", "password", "database") 
      
    local accountname = getAccountName( getPlayerAccount( player ) ) 
    local driftpoints = driftpoints 
      
    mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname  .. "' ") 
    

    something like that, then on your register script you should make it insert them into the users table or whatever.

    so i need to put that into my register script? and what you mean whit that? the internal.db?

    No, that script wouldn't work alone, it's just to give you an idea of what you need to do.

    So you'd make a table called users in your mysql database, then in your register script you'd make it insert the user into the database/table.

    then when you want to update driftpoints you'd do

    local handler = mysql_connect("localhost", "root", "password", "database") 
      
    local accountname = getAccountName( getPlayerAccount( player ) ) 
    local driftpoints = driftpoints 
      
    mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname  .. "' ") 
    

    Or something simular.

  11. I will be starting work on an open source housing system, as this is open source I'll be updating this page with snippets, updates and features. The main reason for this topic is so I can get feedback on what you'd like to see and what could be improved. Please post below any ideas you may have, or if you think there is a better way I could be doing stuff. You'll be given full credit for any contributions you decide to make.

    How will I create a house?

    Simple, You just type /addhouse and the system will then generate a random interior and dimension. This makes it easier for mass house creation.

    Folder Structure:

    - RPhousing

    --Client

    ---gui.lua

    --Server

    ---commands.lua

    ---core.lua

    ---database.lua

    ---houseFunctions.lua

    --Shared

    ---data.lua

    --Ext

    ---housing.db

    VIEW SOURCE

    https://github.com/MagicMayhemC/HousingSYS

    Planned features;

    - Basic Features

    You'll be able to lock, sell and enter your home.

    - Housing Storage

    You will have the ability to store items in your house.

    UPDATES:

    - You can now enter and leave houses

    I will be updating this topic daily with a list of updates, feel free to contribute to this development.

    Screenies;

    07b75084f95f8c134899c26690d66a9a.png

×
×
  • Create New...