Jump to content

Blueman

Members
  • Posts

    110
  • Joined

  • Last visited

Posts posted by Blueman

  1. I never called setElementMoney in my code.. I called setPlayerMoney because when I called givePlayerMoney(source, 1000) it would do nothing...

    Cleaned up the code and added some comments.

    This is a bit different than the original since i've been working on it but it does not seem to be destroy the map blip

    local hasBeenCollected=true 
    local theDrug 
      
    local locx,locy,locz,hint={-2923.1591, -1126.8721}, 
                              {1165.1446, 834.1354}, 
                              {13.5312, 3.0777}, 
                              {"The back yards of san fiero", 
                              "A oceanic rock next to a bridge support"} --An array with drug package locations and hints 
      
    function pickedUpDrug(pickup,dimension) -- Called when something is picked up. 
        if(getElementData(pickup, "rpg.drug") == "a") then 
            local earnings=math.random(2000)--Generate random earnings from 1 to 2000 
            local money = getPlayerMoney(source) 
            setPlayerMoney(source , money + earnings)--Give player money does nothing where as this seems to work fine. 
            hasBeenCollected = true --Tell setupDrugRun we've collected it 
            destroyElement(getElementAttachedTo(pickup))--Destroy the pickups blip(does not seem to work) 
            destroyElement(pickup)--Make sure we destroy our pickup 
            outputChatBox ( getPlayerName(source).." has collected the drug package for $"..earnings, getRootElement(), 0, 0, 255, true )--Tell everyone about it 
        elseif(getElementData(pickup, "rpg.money") == "mons") then --This can be ignored it has nothing to do with the drug run 
            local money = getPlayerMoney(source) 
            setPlayerMoney(source , money + 100) 
            destroyElement(pickup) 
             
        end 
    end 
      
    function setupDrugRun() 
        if(hasBeenCollected == true) then --Has our drug package been collected 
            hasBeenCollected=false --If so reset it 
            local location=math.random(2) --Choose a random location from the array 
            theDrug = createPickup ( locx[location], locy[location], locz[location], 3, 1279) --Possibly not passing the element to theDrug 
            createBlipAttachedTo ( theDrug, 36) 
            setElementData(theDrug, "rpg.drug", "a")--We cannot pass theDrug to addEventHandler as element(Perhaps a bug or user error) 
            outputChatBox ( "A new drug package is available for pick up", getRootElement(), 0, 0, 255, true )--Tell everyone about it. 
        end 
    end 
    function startDrugRun() --Sets up the timer for the drug run this can be ignored 
        setTimer(setupDrugRun, 1000, 0) 
    end 
    addEventHandler("onResourceStart", resourceRoot, startDrugRun)--Starts up the timer on resource start. 
    addEventHandler("onPlayerPickupUse",root,pickedUpDrug) --Replacing root with theDrug results in nothing 
      
    

  2. It seems the givePlayerMoney is not behaving as it should in this case. I get output into the chatbox but I receive no money.

    local hasBeenCollected 
    local theDrug 
    local locx,locy,locz={-2923.1591},{1165.1446},{13.5312} 
    function pickedUpDrug(pickup,dimension) 
        if(getElementData(theDrug, "rpg.drug") == "a") then 
        local dbgmny = setPlayerMoney(source, 20000) 
        if(dbgmny == false) then 
        outputChatBox("Error money", getRootElement(), 0, 0, 255, true) 
        end 
        outputChatBox ( getPlayerName(source).." has collected the drug package", getRootElement(), 0, 0, 255, true ) 
        end 
    end 
    function setupDrugRun() 
        hasBeenCollected=false 
        local location=math.random(1) 
        theDrug = createPickup ( locx[location], locy[location], locz[location], 3, 1279) 
        setElementData(theDrug, "rpg.drug", "a") 
         
         
        outputChatBox ( "A new drug package is available for pick up", getRootElement(), 0, 0, 255, true ) 
    end 
    addEventHandler("onResourceStart", resourceRoot, setupDrugRun) 
    addEventHandler("onPlayerPickupUse",root,pickedUpDrug) 
    

    Please mind the messy code, also I should note that I used setElementData because when I called addEventHandler("onPickupUse", theDrug, pickedUpDrug) I would get no output at all.

  3. If this is your gamemode you must use spawnPlayer() in order to spawn the players at start.

      
    local X= 
    local Y= 
    local Z= 
    --Write your spawn coordinates after the X, Y and Z 
    function PLJOIN() 
        spawnPlayer(source, X, Y, Z) 
        fadeCamera(source, true) 
        setCameraTarget(source, source) 
    end 
    addEventHandler("onPlayerJoin", getRootElement(), PLJOIN) --Change this to "onPlayerLogin" if you want players to spawn at login 
      
    

  4. Thanks I am not looking to do much I am just scripting for fun and the problem is it wouldn't save to the xml file but I will see if yours works. Also the script was just a test script thanks.

    Note: I was pretty tired when I wrote this so the debug string thing was probably due to that. :3

  5. It seems when I execute this code it doesn't save to the xml file like it is intended to.

    Ranks.xml

      
     <Ranks> 
        <gameranks> 
         
        </gameranks> 
    </Ranks> 
      
    

    Meta.xml

      
    <meta> 
    <info name="RankSystem" author="Blueman" version="1.0.0" type="script"></info> 
    <script src="Main.lua" type="server"/> 
    <file src="Ranks.xml" /> 
    </meta> 
      
    

      
    Ranks = xmlLoadFile ( "Ranks.xml" ) 
    function createRank(INT, Label) 
    if (INT) and (Label) then 
      local GR = xmlFindChild(Ranks,"gameranks",0) 
      if (xmlFindChild(GR, INT)) then 
      outputDebugSting("That rank has been created already") 
      else 
        xmlNodeSetValue (xmlCreateChild (GR , INT), Label ) 
        xmlSaveFile(Ranks) 
        end 
        else 
        outputDebugString("In function createRank() incorrect arguments") 
     end 
    end 
      
    

    Any help would be appreciated.

  6. It seems that no one accept me is able to connect to my server. My ports are forwarded properly I made sure the firewall was set up right and yet no one can connect. I have no problem with my other servers such as my http and MC server.

    Also a little thing to note is that it is unable to connect to game-monitor.com it says it is unavailable.

  7. One problem you set the amount of times to repeat to 0 causing an infinite loop.

      
    local PingTable = { } 
      
    local default_time = 10000 
      
    addEventHandler( 'onPlayerJoin', root, 
        function( ) 
            PingTable [ source ] = setTimer( 
                function( player ) 
                    if getPlayerPing( player ) > tonumber( get( 'MaxPing' ) ) then 
                        kickPlayer( player, "High Ping" ) 
                    else 
                        outputDebugString( '*'..getPlayerName( player ).. ' Has passed the ping check' ) 
                    end 
                end, 
            tonumber( get( "Delay" ) or default_time ), 
            1 , source )    
        end 
    ) 
      
    addEventHandler( 'onPlayerQuit', root, 
        function( ) 
            if isTimer( PingTable [ source ] ) then 
                killTimer( PingTable [ source ] ) 
            end 
            PingTable [ source ] = nil 
        end 
    ) 
      
    

  8. Well the console keeps claiming that this is a string then I make some changes to convert it from a string to a int and it says it is a Boolean.

    Ping.lua

      
    PingTable = { } 
      
    function PingCheck(source) 
    if (getPlayerPing(sourcer) > get("MaxPing")) then 
        kickPlayer(ThePlayer, "High Ping") 
    else 
       outputConsle( ThePlayer.. "Has passed the ping check") 
     end 
    end 
      
    function onPlayerJoinGame() 
    table.insert(PingTable ,setTimer(PingCheck, tonumber(get("Delay")), 1 , source) 
    ) 
    end 
    addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoinGame) 
      
    

    Meta.xml

      
    <Meta> 
    <info author="Blueman" type="script" name="Ping Kicker" /> 
    <script src="Ping.lua" type="server"/> 
    <settings>  
    <setting name="MaxPing" value="50"/>  
    <setting name="Delay" value="10000"/> 
    </settings> 
    </Meta> 
      
    

  9. You can just put a script in a function and execute that function when needed like so.

      
    function excutor() 
    --A bunch of code here. 
    CODE() 
    --A bunch of code here. 
    end 
    function CODE() 
    --Your code to be executed here. 
    end 
      
    

  10. The goal of this script is to make the player invincible but the server sided command doesn't work for some reason.

    server:

      
    function setInince(user, commandname) 
    if (hasObjectPermissionTo(user, "function.banPlayer")) then 
       if (getElementData(user, "INV") == "true") then 
          setElementData("INV", "false") 
          outputChatBox("You are no longer Invincible", user) 
       else 
         setElementData("INV", "true") 
        outputChatBox("You are now Invincible", user) 
    else  
        outputChatBOX("You do not have permission for this", user) 
       end 
     end 
    end 
    addCommandHandler("INCI", setInince) 
      
    

    Client:

      
    function noadmdamage() 
    if (getElementData(source, "INV") == "true") then 
        cancelEvent() 
    else 
     end 
    end 
    addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) 
      
    

  11. While browsing for errors in MTA's memory I found this it is some of the remains of a virus I removed any explanation?

    Data Address: 0x00164aa0

    Header Address 0x00164a98

    Heap Handle: 0x00160000

      
    00164AA0  00 00 00 00 00 01 00 00 00 00 00 00 A0 4D 16 00    .............M.. 
    00164AB0  16 00 18 00 50 39 3F 00 46 00 48 00 20 39 3F 00    ....P9?.F.H. 9?. 
    00164AC0  4E 00 2A 02 50 4B 16 00 0C 00 19 00 7A 4D 16 00    N.*.PK......zM.. 
    00164AD0  00 00 00 00 00 00 00 00 18 00 32 00 98 B1 00 10    ..........2..... 
    00164AE0  00 00 00 00 00 00 00 00 01 00 19 00 56 00 00 00    ............V... 
    00164AF0  04 01 00 00 00 00 00 00 D8 3A 3F 00 01 01 A3 00    .............. 
    00164B00  DD 00 A3 00 01 01 A3 00 0C 00 0C 00 01 00 A3 00    ................ 
    00164B10  09 00 09 00 DD 00 A3 00 18 00 18 00 E7 00 A3 00    ................ 
    00164B20  08 4B 16 00 10 4B 16 00 18 4B 16 00 00 00 00 00    .K...K...K...... 
    00164B30  00 00 00 00 00 00 00 00 05 00 23 00 5E 01 08 00    ..........#.^... 
    00164B40  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ 
    00164B50  5C 00 3F 00 3F 00 5C 00 63 00 3A 00 5C 00 50 00    \.?.?.\.c.:.\.P. 
    00164B60  72 00 6F 00 67 00 72 00 61 00 6D 00 20 00 46 00    r.o.g.r.a.m. .F. 
    00164B70  69 00 6C 00 65 00 73 00 5C 00 42 00 61 00 6E 00    i.l.e.s.\.B.a.n. 
    00164B80  64 00 6F 00 6F 00 5C 00 70 00 6C 00 75 00 67 00    d..\.p.l.u.g. 
    00164B90  69 00 6E 00 73 00 2E 00 69 00 6E 00 69 00 00 00    i.n.s...i.n.i... 
    00164BA0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ 
    00164BB0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ 
    00164BC0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ 
      
    

  12. Actually, its just a sync problem. Indeed you see the player getting hit but not gettig damage. Reason: A banshee has two forms, a closed and open roof. Open roof makes shots hit the player from any open sight. Closed roof does not. Yes, you recorded an open roof. But what about the other player? He might have had a closed roof and thus causing your bullets to act different. So, this is not a bug or whatever: The car form doesn't get synced.

    Second, the driveby. I can't give a logical explaination for this, most likely MTA doesnt sync it's new position when performing an animation inside a car. It might not give any problems when performing that animation without being in a car.

    It's not sync but some things that aren't carried over to MTA so you can't shoot him/her from above.

  13. Thank you so much :D i owe ya and how would i add collision zone and no commands, lol. Everyone on my server couldnt open the gates. If you come close to it it opens and you can edit the size etc.. or copy it from gate maker script.

    Update i think i got it i got a gate script from mta community and im editing it and making multiple scripts for each gate and putting the names in the meta.xml wish me luck!

      
    local gate1 = createObject(969, -717.79998779297, 954.20001220703, 11.199999809265, 0, 0, 88) -- First gate 
    local gate2 = createObject(3885, -1498.2347412109, 805.29083251953, 5.7079048156738, 0, 0, 74.915008544922) -- Second gate 
    local gate3 = createObject(2951, 3109.0913085938, -842.58416748047, 28.436388015747, 0, 0, 43.170013427734)  
    gate1col = createColSphere ( -717.79998779297, 954.20001220703, 11.199999809265, 5 ) 
    gate2col = createColSphere ( -1498.2347412109, 805.29083251953, 5.7079048156738, 5 ) 
    gate3col = createColSphere ( -3109.0913085938, 805.29083251953, 5.7079048156738, 5 ) 
    local s2 = createBlip(2920.76171875, -842.58416748047, 28.436388015747, 23) -- The Blip 
      
    -- Open the gate 1 
    function openGate1() 
        moveObject(gate1, 2500, -718, 946.90002441406, 11.199999809265) 
        gatetimer(closeGate1) 
    end 
    addEventHandeler("onElementColShapeHit", gate1col, openGate1) 
      
    function gatetimer(TheFunction) 
    setTimer(TheFunction, 10000, 1 ) 
    end 
      
      
    -- Close the gate 1 
    function closeGate1() 
        moveObject(gate1, 2500, -717.79998779297, 954.20001220703, 11.199999809265) 
    end 
      
      
    -- Open the gate 2 
    function openGate2() 
        moveObject(gate2, 2200, -1497.6064453125, 805.119140625, 50.178058624268) 
        gatetimer(closeGate2) 
    end 
    addEventHandeler("onElementColShapeHit", gate2col, openGate2) 
      
      
    -- Close the gate 2 
    function closeGate2() 
        moveObject(gate2, 2450, -1498.2347412109, 805.29083251953, 5.7079048156738) 
    end 
      
      
      
    function openGate3() 
        moveObject(gate3, 2200, 3109.0908203125, -842.63531494141, 24.53639793396) 
        gatetimer(closeGate3) 
    end 
    addEventHandeler("onElementColShapeHit", gate3col, openGate3) 
      
      
    function closeGate3() 
        moveObject(gate3, 2450, 3109.0913085938, -842.58416748047, 28.436388015747) 
    end 
      
      
    

    Note: Might not work I haven't scripted in a while!

  14. It's already in my downloads folder so I assumed it was the same one but i'll try it. :)

    Edit:

    I'll see if it's fixed during the next update it appears to be a conflict between my hardware and the method it's being rendered. :|

    Edit: I've found the problem mta keeps trying to load something into address 00000000 and is returning Address: 00000000 is Not in a Loaded Module

    ****** Data is Not Accessible ******

×
×
  • Create New...