Jump to content

drk

Members
  • Posts

    1,607
  • Joined

  • Last visited

Posts posted by drk

  1. Remove tonumber from xmlFindChild, it's already triggered as number. Anyway, wait for other person, I'm not going to post here because some retardeds will start saying some shits like Solidsnaka.

  2. elseif ( source == ButtonBuyHouse ) then 
        local nHouse = guiGetText ( housenumber ); 
        triggerServerEvent ( 'HouseSystemBuyHouse', localPlayer, tonumber ( nHouse ) ); 
    end 
    

    server side :

    addEvent("HouseSystemBuyHouse",true) 
    addEventHandler ("HouseSystemBuyHouse", getRootElement(), 
    function(housenumber) 
      local root = xmlLoadFile ("homes.xml") 
      local houseHeadRootNode = xmlFindChild (root,"houses",0) 
      local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber))   
      local price = xmlNodeGetAttribute (houseRootNode,"cost") 
      local owner = xmlNodeGetAttribute (houseRootNode,"owner") 
      if not (isGuestAccount (getPlayerAccount(source))) then 
        if (owner == "") and (getPlayerMoney (source) >= tonumber(price)) then 
          takePlayerMoney (source,tonumber(price)) 
          xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source))) 
          outputChatBox ("Congratulations, you are the new owner!",source,255,0,0,false) 
          outputChatBox ("Price: ".. tostring(price) .. "$!",source,255,0,0,false) 
          for i,v in ipairs ( getElementsByType("pickup")) do 
                local number = getElementData ( v, "housenumber" ) 
                if ( number == housenumber ) then 
                setPickupType ( v, 3, 1272 ) 
                end 
                end 
          xmlSaveFile (root) 
        elseif not (owner == "") then 
          outputChatBox ("This house is already Bought!",source,255,0,0,false) 
        elseif (getPlayerMoney (source) < tonumber(price)) then 
          outputChatBox ("Sorry, you are too poor!",source,255,0,0,false) 
        end 
      end 
      xmlUnloadFile (root)   
    end 
    ) 
    

  3. You don't like "Are you sure you never called? You must pay more attention in what you say ^^" ??

    If not, why when I say something about, you say the same "I don't want to argue with you" ??

    Anyway, I will not lost my time with you, it's a waste.

  4. Are you sure you never called? You must pay more attention in what you say ^^

    I can't test scripts in my machine because it sucks and if you have missed something already, why don't you just shut up?

    And maybe I have somethings wrong because I made it fast, I said it's correct?

  5. First, why don't you stop calling others "KID" when you're one, Solidsnaka?

    Second, I forgot "Your table contained strings, not numbers.", what the problem? You never missed something?

    Third, "You had "rAreas" instead of "gAreas" in the second loop." LOL?

    Fourth, You don't need the fucking onClientResourceStart event.

  6. You're wrong and Aibo too xD

    First, in your code, values is nil.

    And Aibo, I tested it some times. You don't need create functions first, believe me. I can show the part of my GangWar where I add handlers first and then functions and work.

  7. local rAreas = { }; 
    local gAreas = { }; 
      
    local tRedAreas = 
    { 
        { fX = 200, fY = 100, fWidth = 500, fHeight = 500 }; 
        { fX = 300, fY = 50, fWidth = 250, fHeight = 300 }; 
    } 
      
    local tGreenAreas = 
    { 
        { fX = 200, fY = 100, fWidth = 500, fHeight = 500 }; 
        { fX = 300, fY = 50, fWidth = 250, fHeight = 300 }; 
    } 
      
    for _, rArea in pairs ( tRedAreas ) do 
        rAreas[_] = createColRectangle ( rArea.fX, rArea.fY, rArea.fwidth, rArea.fHeight ); 
        addEventHandler ( 'onColShapeHit', rAreas[_], onRectangleHit ); 
        addEventHandler ( 'onColShapeLeave', rAreas[_], onRectangleLeave ); 
    end 
      
    for _, gArea in pairs ( tGreenAreas ) do     
        gAreas[_] = createColRectangle ( gArea.fX, gArea.fY, gArea.fWidth, gArea.fHeight ); 
        addEventHandler ( 'onColShapeHit', gAreas[_], onRectangleHit ); 
        addEventHandler ( 'onColShapeLeave', gAreas[_], onRectangleLeave ); 
    end 
      
    onRectangleHit = function ( uPlayer ) 
        outputChatBox ( getPlayerName ( uPlayer ) .. ' entered the ColShape!', root, 255, 255, 255, false ); 
    end 
      
    onRectangleLeave = function ( uPlayer ) 
        outputChatBox ( getPlayerName ( uPlayer ) .. ' left the ColShape!', root, 255, 255, 255, false ); 
    end 
      
    

  8. "what could be the easieast way for me, to make it without crashing server?"

    MySQL? MySQL doesn't crash the server.

    "the problem i have is to convert server to run in mysql, first of all, is here any1 who could tell me how to get simple user panel, which is made to mysql"

    I have two, not mine, I never looked into the code, I will see if it uses MySQL.

    -- If you need help with MySQL, just post here and we help :)

  9.      local tVehicles = -- what draken was saying is, its alot easier to find and edit it now, the code looks more organized too. 
        { 
            [ 598 ] = true; 
            [ 596 ] = true; 
            [ 597 ] = true; 
            [ 411 ] = true; 
            [ 599 ] = true; 
        } 
      
     -- Simple Police-Lights by MuLTi! 
          
        p_lights = {} 
        p_timer = {} 
        p_lvar = {} 
        p_pvar = {} 
        p_lvar2 = {} 
        p_lvar3 = {} 
        p_lvar4 = {} 
          
          
          
        function toggleLights(thePlayer, cmd, level) 
            local level = tonumber(level) 
            if not(level) then outputChatBox("#FF0000 Please select a level![1-2]", thePlayer, 255, 255, 255, true) return end 
            if(level < 1) or (level > 2) then outputChatBox("#FF0000 Please select a level between 1-2!", thePlayer, 255, 255, 255, true) return end 
            local veh = getPedOccupiedVehicle(thePlayer) 
            local id = getElementModel(veh) 
         
             if ( tVehicles [ getPedOccupiedVehicle ( thePlayer ) ] ) then 
                if(level == 1) then 
                    if(p_lights[veh] == 0) or(p_lights[veh] == nil) then 
                        p_pvar[veh] = 1 
                        p_lights[veh] = 1 
                        outputChatBox("#FFFFFFYour Police-lights has been #00FF00enabled.", thePlayer, 0, 200, 100, true) 
                        setVehicleOverrideLights ( veh, 2 ) 
                        p_timer[veh] = setTimer( 
                        function() 
                            if(p_lvar[veh] == 0) or (p_lvar[veh] == nil) then 
                                p_lvar[veh] = 1 
                                setVehicleLightState ( veh, 1, 0) 
                                setVehicleLightState ( veh, 2, 0) 
                                setVehicleLightState ( veh, 0, 1) 
                                setVehicleLightState ( veh, 3, 1) 
                                setVehicleHeadLightColor(veh, 0, 0, 255) 
                            else 
                                setVehicleLightState ( veh, 3, 0) 
                                setVehicleLightState ( veh, 0, 0) 
                                setVehicleLightState ( veh, 1, 1) 
                                setVehicleLightState ( veh, 2, 1)   
                                setVehicleHeadLightColor(veh, 255, 0, 0) 
                                p_lvar[veh] = 0 
                            end 
                        end, 500, 0) 
                        else 
                            p_lights[veh] = 0 
                            outputChatBox("#FFFFFFYour Police-lights has been #00FF00disabled.", thePlayer, 0, 200, 100, true) 
                            killTimer(p_timer[veh]) 
                            setVehicleLightState ( veh, 0, 0) 
                            setVehicleLightState ( veh, 1, 0) 
                            setVehicleLightState ( veh, 2, 0) 
                            setVehicleLightState ( veh, 3, 0)   
                            setVehicleHeadLightColor(veh, 255, 255, 255) 
                            setVehicleOverrideLights ( veh, 1 ) 
                        end 
                    elseif(level == 2) then 
                        if(p_lights[veh] == 0) or(p_lights[veh] == nil) then 
                        p_lights[veh] = 1 
                        outputChatBox("#FFFFFFYour Police-lights has been #00FF00enabled.", thePlayer, 0, 200, 100, true) 
                        setVehicleOverrideLights ( veh, 2 ) 
                        p_timer[veh] = setTimer( 
                        function() 
                            if(p_lvar3[veh] == 4) then 
                                setTimer(function() p_lvar3[veh] = 0 end, 1000, 1) 
                                setTimer( 
                                function() 
                                    if(p_lvar4[veh] == 1)then 
                                        p_lvar4[veh] = 0 
                                        -- 0 = vorne links 1 = vorne rechts 2 = hinten links 3 = hinten rechts 
                                        setVehicleLightState ( veh, 1, 0) 
                                        setVehicleLightState ( veh, 2, 0) 
                                        setVehicleLightState ( veh, 0, 1) 
                                        setVehicleLightState ( veh, 3, 1) 
                                        setVehicleHeadLightColor(veh, 77, 77, 255) 
                                    else 
                                        setVehicleLightState ( veh, 3, 0) 
                                ш      setVehicleLightState ( veh, 0, 0) 
                                        setVehicleLightState ( veh, 1, 1) 
                                        setVehicleLightState ( veh, 2, 1)   
                                        setVehicleHeadLightColor(veh, 255, 77, 77) 
                                        p_lvar4[veh] = 1 
                                    end 
                                end, 50, 5) 
                            return end 
                            if(p_lvar2[veh] == 0) or (p_lvar2[veh] == nil) then 
                                p_lvar2[veh] = 1 
                                -- 0 = vorne links 1 = vorne rechts 2 = hinten links 3 = hinten rechts 
                                setVehicleLightState ( veh, 1, 0) 
                                setVehicleLightState ( veh, 2, 0) 
                                setVehicleLightState ( veh, 0, 1) 
                                setVehicleLightState ( veh, 3, 1) 
                                setVehicleHeadLightColor(veh, 0, 0, 255) 
                            else 
                                setVehicleLightState ( veh, 3, 0) 
                                setVehicleLightState ( veh, 0, 0) 
                                setVehicleLightState ( veh, 1, 1) 
                                setVehicleLightState ( veh, 2, 1)   
                                setVehicleHeadLightColor(veh, 255, 0, 0) 
                                p_lvar2[veh] = 0 
                            end 
                            if(p_lvar3[veh] == nil) then p_lvar3[veh] = 0  end 
                            p_lvar3[veh] = (p_lvar3[veh]+1) 
                        end, 500, 0) 
                        else 
                            p_lights[veh] = 0 
                            outputChatBox("#FFFFFFYour Police-lights has been #00FF00disabled.", thePlayer, 0, 200, 100, true) 
                            killTimer(p_timer[veh]) 
                            setVehicleLightState ( veh, 0, 0) 
                            setVehicleLightState ( veh, 1, 0) 
                            setVehicleLightState ( veh, 2, 0) 
                            setVehicleLightState ( veh, 3, 0)   
                            setVehicleHeadLightColor(veh, 255, 255, 255) 
                            setVehicleOverrideLights ( veh, 1 ) 
                        end 
                        end 
                    end 
        end 
        addCommandHandler("lights", toggleLights) 
          
          
          
        addEventHandler ( "onVehicleExplode", getRootElement(), 
        function() 
            if(p_lights[source] == 1) then 
                killTimer(p_timer[source]) 
            end 
        end ) 
          
        addEventHandler ( "onVehicleRespawn", getRootElement(), 
        function() 
            if(p_lights[source] == 1) then 
                killTimer(p_timer[source]) 
            end 
        end ) 
          
        addEventHandler("onElementDestroy", getRootElement(), 
        function () 
            if getElementType(source) == "vehicle" then 
                if(p_lights[source] == 1) then 
                    killTimer(p_timer[source]) 
                end 
            end 
        end) 
    

  10. You should tabulate the code.

    Client-side:

    addEvent ( 'loadAtClient', true ); 
      
    local name = guiCreateLabel ( 50, 10, 410, 20, '', false, tab ); 
      
    addEventHandler ( 'onClientPlayerJoin', root, 
        function ( ) 
            triggerServerEvent ( source, 'loadData', source ); 
        end 
    ) 
      
    addEventHandler ( 'loadAtClient', root, 
        function ( nData ) 
            if ( not nData ) then 
                return; 
            end 
             
            guiSetText ( name, tonumber ( nData ) ); 
        end 
    ) 
    

    Server-side:

    addEvent ( 'loadData', true ); 
      
    addEventHandler ( 'loadData', root, 
        function ( ) 
            local fData = xmlLoadFile ( 'score.xml' ); 
            if ( fData ) then 
                local fNode = xmlFindChild ( fData, 'flos1', 0 ); 
                local fValue = xmlNodeGetValue ( fNode ); 
                triggerClientEvent ( source, 'loadAtClient', source, fValue ); 
            end 
        end 
    ) 
    

  11. The code seems to work.

    Also, use:

    local tVehicles = 
    { 
        [ 598 ] = true; 
        [ 596 ] = true; 
        [ 597 ] = true; 
        [ 411 ] = true; 
        [ 599 ] = true; 
    } 
    

    instead.

    Example:

    local tVehicles = 
    { 
        [ 598 ] = true; 
        [ 596 ] = true; 
        [ 597 ] = true; 
        [ 411 ] = true; 
        [ 599 ] = true; 
    } 
      
    if ( tVehicles [ getPedOccupiedVehicle ( thePlayer ) ] ) then 
        -- something here 
    end 
    

  12. ebacol = createColSphere( -1276.9361572266, 54.15234375, 65.905364990234, 7 ) 
    state = createColPolygon ( 0, 0, -4000, -4000, -4000, 4000, 4000, 4000, 4000, -4000 ) 
    blips = { } 
      
    function atcDut ( source ) 
        local isittrue = isElementWithinColShape ( source, ebacol ) 
        if ( isittrue == true ) then 
            local atcvehs = getElementsWithinColShape( state, "vehicle" ) 
            for index, vehicle in ipairs ( atcvehs ) do 
                local vehmod = getElementModel ( vehicle ) 
                if ( vehmod == 487 ) then 
                    table.insert ( blips, createBlipAttachedTo ( vehicle, 0, 2, 0, 200, 255, 255, 0, 99999, source ) ) 
                end 
            end 
            outputChatBox ( "You are now on ATC Duty", source ) 
        end 
    end 
    addCommandHandler ( "atcduty", atcDut ) 
      
    function eatcDut ( source ) 
        local isittrue = isElementWithinColShape ( source, ebacol ) 
        if ( isittrue == true ) then 
            for index, blip in ipairs ( blips ) do 
                if ( isElement ( blip ) ) then 
                    destroyElement ( blip ) 
                end 
            end 
            outputChatBox ( "You are now off ATC Duty", source ) 
        end 
    end 
    addCommandHandler ( "endduty", eatcDut ) 
    

×
×
  • Create New...