Jump to content

Prywatne auta


Recommended Posts

Posted (edited)

Cześć.

Uploduje tu prywatny system aut.

Posiada:

- zapis pojazdu w ostatniej pozycji, koloru i upgrade'ów

- zapis do SQL/MySQL

- pełną konfiguracje

- panel tworzenia auta pod 'Z' albo /privatecars

Zexportowane funkcje:

createPrivateVehicle ( int model, int x, int y, int z, int rotX, int rotY, int rotZ, table color, table upgrades, string accName ) 

tablica kolorów powinna wyglądać { r, g, b, r1, g1, b1, r2, g2, b2, r3, g3, b3, r4, g4, b4 }

isCarPrivate ( element vehicle ) 

getPrivateCarOwner ( element vehicle ) 

Wszystkie funkcje po stronie serwera.

Wbudowane komendy:

/carinfo

Zdjęcia:

http://imgur.com/sMiYSLj,UpFjofz,mu5wL58

sMiYSLj.jpg

UpFjofz.jpg

mu5wL58.jpg

Plik konfiguracyjny

--[[ 
    PRIVATE CARS 
    by WhoAmI (aka Jacob) 
    You are able to modify the script, if you don't change author. 
    #config.lua 
]]-- 
  
--[[ change if you wish 
    availible values: 
        - MySQL 
        - SQL 
]]-- 
connectionType = "SQL"; 
  
-- ONLY if you chose MySQL 
MySQLdbhost = "localhost"; -- host 
MySQLdbname = "test"; -- database name 
MySQLdbuser = "root"; -- database user 
MySQLdbpassword = ""; -- user's password 
-- end 
  
-- ONLY if you chose SQL 
SQLfilename = "example.db"; -- choose name for databse file 
--[[ WARNING! without ".db" at the and it won't work. 
     REMEMBER! you have to add following line to meta.xml: 
          <file src="YOUR_NAME.db" /> 
     AND create this file! 
     otherwise, SQL won't work. REMEMBER! 
end ]]-- 
  
  
-- ACL groups allowed to create private car 
aclGroups = { 
    "Admin", 
    "Moderator", 
}; 
-- end 
  
-- ACL groups allowed to see car info 
aclGroupsInfo = { 
    "Everyone", 
}; 
-- end 
  
-- command name for car's information 
carInfoCommandName = "carinfo"; 
-- end 
  
-- time after the vehicle will be fixed after explosion IN SECONDS 
respawnTime = 10; 
-- end 

Download

https://community.multitheftauto.com/index.php?p= ... s&id=11268

Skrypt jest po angielsku. Błędy proszę zgłaszać.

Powodzenia. :)

Edited by Guest
Posted

wszystko działa jak powinno a da się zrobić aby podnośnik go odmrażał podczas holu?

,,NIE WAŻNE JAK UPADASZ WAŻNE JEST JAK SIĘ PODNOSISZ.''

Posted

Zrób swój skrypt, może działać w ten sposób np.

- PD wchodzi do auta, wpisuje komendę

- samochód zostaje odmrożony funckją

setElementFrozen 

- PD zawozi na baze, wpisuje ponownie komende freezując samochód

setElementFrozen 

Pozdrawiam.

Posted

Tak to ma wyglądać?:

function toggleFreezeStatus ( thePlayer ) 
  
if isObjectInACLGroup("user." .. accountname, aclGetGroup("Pd")) then  
  
if getPedOccupiedVehicle ( thePlayer ) then 
  
local playerVehicle = getPlayerOccupiedVehicle ( thePlayer ) 
  
local currentFreezeStatus = isElementFrozen ( playerVehicle ) 
  
local newFreezeStatus = not currentFreezeStatus 
  
setElementFrozen ( playerVehicle, newFreezeStatus ) 
  
end 
  
end 
  
end 
  
  
  
local connectedPlayers = getElementsByType ( "player" ) 
  
for i, aPlayer in ipairs(connectedPlayers) do 
  
addCommandHandler ( "reczny", toggleFreezeStatus ) 
  
end 

Aha i szkoda ze po restarcie skryptu auta znikaja

,,NIE WAŻNE JAK UPADASZ WAŻNE JEST JAK SIĘ PODNOSISZ.''

Posted

Tak mam ten plik wszystko dziala jak powinno lecz lko po restart znikaja pokazac mam ten plik? A co z pierwszym pytaniem?

,,NIE WAŻNE JAK UPADASZ WAŻNE JEST JAK SIĘ PODNOSISZ.''

Posted

Podaj mi co jest w debugu i czy przerabiałeś jakoś skrypt?

function toggleFreezeStatus ( thePlayer ) 
    local account = getPlayerAccount ( thePlayer ) 
    if ( not isGuestAccount ( account ) ) then 
        local accountName = getAccountName ( account ) 
        if ( isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Pd" ) ) then 
            if ( isPedInVehicle ( thePlayer ) ) then 
                local vehicle = getPedOccupiedVehicle ( thePlayer ) 
                setElementFrozen ( vehicle, not isElementFrozen ( vehicle ) ) 
            end 
        end 
    end 
end 
addCommandHandler ( "reczny", toggleFreezeStatus ) 

Posted

Tak zmienilem komendy te dwie i spolszczylem outputChatBox a buga nie dam bo nie jestem w grze

,,NIE WAŻNE JAK UPADASZ WAŻNE JEST JAK SIĘ PODNOSISZ.''

Posted
aclGroup = "Urzad" -- who can create car 
aclGroupInfo = "Everyone" -- who can see info about car 
  
-- dont touch this 
local last_id = 0 
-- dont touch this 
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        connection = dbConnect ( "sqlite", "vehicles.db" ) 
        if ( not connection ) then 
            outputDebugString ( "PRIVATE CARS: Failed to connect to database.", 3, 255, 0, 0 ) 
            return 
        end 
         
        local creatingTable = dbExec ( connection, "CREATE  TABLE  IF NOT EXISTS `vehicles` (`id` INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL, `vehicle_model` INTEGER, `x` INTEGER, `y` INTEGER, `z` INTEGER, `rotX` INTEGER, `rotY` INTEGER, `rotZ` INTEGER, `r` INTEGER, `g` INTEGER, `b` INTEGER, `acc_name` TEXT )" ) 
        if ( not creatingTable ) then 
            outputDebugString ( "PRIVATE CARS: Failed to create table.", 3, 255, 0, 0 ) 
            return 
        end 
         
        local query = dbQuery ( connection, "SELECT * FROM `vehicles`" ) 
        local result = dbPoll ( query, -1 ) 
        for _, data in pairs ( result ) do 
            local vehicle = createVehicle ( data [ "vehicle_model" ], data [ "x" ], data [ "y" ], data [ "z" ], data [ "rotX" ], data [ "rotY" ], data [ "rotZ" ] ) 
            if ( isElement ( vehicle ) and getElementType ( vehicle ) == "vehicle" ) then 
                if ( tonumber ( data [ "id" ] ) > last_id ) then 
                    last_id = data [ "id" ] 
                end 
             
                setVehicleColor ( vehicle, data [ "r" ], data [ "g" ], data [ "b" ], data [ "r" ], data [ "g" ], data [ "b" ], data [ "r" ], data [ "g" ], data [ "b" ], data [ "r" ], data [ "g" ], data [ "b" ] ) 
                setElementData ( vehicle, "private", true ) 
                setElementData ( vehicle, "accName", data [ "acc_name" ] ) 
                setElementData ( vehicle, "id", data [ "id" ] ) 
                setElementFrozen ( vehicle, true ) 
            end 
        end 
    end 
) 
  
-- SAVING 
addEventHandler ( "onResourceStop", resourceRoot, 
    function ( ) 
        for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
            if ( isCarPrivate ( vehicle ) ) then 
                local x, y, z = getElementPosition ( vehicle ) 
                local rX, rY, rZ = getElementRotation ( vehicle ) 
                local r, g, b = getVehicleColor ( vehicle, true ) 
                local id = getElementData ( vehicle, "id" ) 
                 
                local updating = dbExec ( connection, "UPDATE `vehicles` SET `x`=?, `y`=?, `z`=?, `rotX`=?, `rotY`=?, `rotZ`=?, `r`=?, `g`=?, `b`=? WHERE id=?", x, y,z , rX, rY, rZ, r, g, b, id ) 
            end 
        end 
    end 
) 
  
-- USEFUL FUNCTIONS 
function getPlayerFromNamePart(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player 
            end 
        end 
    end 
end 
-- USEFUL FUNCTIONS 
  
function createPrivateCar ( model, player, x, y, z, rX, rY, rZ, r, g, b ) 
    assert ( type ( model ) == "number", "Bad argument #1. Expected number, got " .. type ( model ) .. " @ createPrivateCar" ) 
    assert ( type ( player ) == "userdata", "Bad argument #2. Expected element, got " .. type ( player ) .. " @ createPrivateCar" ) 
     
    assert ( type ( r ) == "number", "Bad argument #3. Expected number, got " .. type ( r ) .. " @ createPrivateCar" ) 
    assert ( type ( g ) == "number", "Bad argument #4. Expected number, got " .. type ( g ) .. " @ createPrivateCar" ) 
    assert ( type ( b ) == "number", "Bad argument #5. Expected number, got " .. type ( b ) .. " @ createPrivateCar" ) 
     
    assert ( type ( x ) == "number", "Bad argument #6. Expected number, got " .. type ( x ) .. " @ createPrivateCar" ) 
    assert ( type ( y ) == "number", "Bad argument #7. Expected number, got " .. type ( y ) .. " @ createPrivateCar" ) 
    assert ( type ( z ) == "number", "Bad argument #8. Expected number, got " .. type ( z ) .. " @ createPrivateCar" ) 
     
    assert ( type ( rX ) == "number", "Bad argument #9. Expected number, got " .. type ( rX ) .. " @ createPrivateCar" ) 
    assert ( type ( rY ) == "number", "Bad argument #10. Expected number, got " .. type ( rY ) .. " @ createPrivateCar" ) 
    assert ( type ( rZ ) == "number", "Bad argument #11. Expected number, got " .. type ( rZ ) .. " @ createPrivateCar" ) 
     
    if ( getElementType ( player ) ~= "player" ) then return false end 
    if ( r < 0 or r > 255 ) then 
        r = 255 
    end 
    if ( g < 0 or g > 255 ) then 
        g = 255 
    end 
    if ( b < 0 or b > 255 ) then 
        b = 255 
    end 
     
    local account = getPlayerAccount ( player ) 
    if ( not isGuestAccount ( account ) ) then 
        local accName = getAccountName ( account ) 
         
        local vehicle = createVehicle ( model, x, y, z, rX, rY, rZ ) 
        setElementData ( vehicle, "id", tonumber ( last_id ) + 1 ) 
        last_id = last_id + 1 
        setElementData ( vehicle, "private", true ) 
        setElementData ( vehicle, "accName", accName ) 
        if ( vehicle ) then 
            setVehicleColor ( vehicle, r, g, b, r, g, b, r, g, b, r, g, b ) 
            local inserting = dbExec ( connection, "INSERT INTO `vehicles` ( `vehicle_model`, `x`, `y`, `z`, `rotX`, `rotY`, `rotZ`, `r`, `g`, `b`, `acc_name` ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )", model, x, y, z, rX, rY, rZ, r, g, b, accName ) 
            if ( inserting ) then 
                return vehicle 
            else 
                destroyElement ( vehicle ) 
                return false 
            end 
        else 
            return false 
        end 
    else 
        return false 
    end 
end 
  
function isCarPrivate ( car ) 
    if ( isElement ( car ) and getElementType ( car ) == "vehicle" ) then 
        local data = getElementData ( car, "private" )       
        if ( data ) then 
            return true 
        else 
            return false 
        end 
    else 
        return false 
    end 
end 
  
function getPrivateCarOwner ( car ) 
    if ( isElement ( car ) and getElementType ( car ) == "vehicle" ) then 
        local data = getElementData ( car, "accName" ) 
        if ( data ) then 
            return tostring ( data ) 
        else 
            return false 
        end 
    else 
        return false 
    end 
end  
  
addCommandHandler ( "daj", 
    function ( player, _, model, r, g, b, playerName ) 
        if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( aclGroup ) ) ) then 
            if ( tonumber ( model ) and tonumber ( r ) and tonumber ( g ) and tonumber ( b ) and tostring ( playerName ) ) then 
                local playerElement = getPlayerFromNamePart ( playerName ) 
                if ( isElement ( playerElement ) and getElementType ( player ) == "player" ) then 
                    local x, y, z = getElementPosition ( player ) 
                    local rX, rY, rZ = getElementRotation ( player ) 
                 
                    setElementPosition ( player, x, y, z + 1 ) 
                    local car = createPrivateCar ( tonumber ( model ), playerElement, tonumber ( x ), tonumber ( y ), tonumber ( z ), tonumber ( rX ), tonumber ( rY ), tonumber ( rZ ), tonumber ( r ), tonumber ( g ), tonumber ( b ) ) 
                    if ( isElement ( car ) and getElementType ( car ) == "vehicle" ) then 
                        outputChatBox ( "Auto " .. model .. " Stworzone dla " .. getPlayerName ( playerElement ) .. ".", root, 255, 255, 255, true ) 
                    end 
                else 
                    outputChatBox ( "Nie mozna znalezc gracza.", player, 255, 255, 255, true ) 
                end 
            end 
        else 
            outputChatBox ( "Nie posiadasz uprawnien do tego!", player, 255, 0, 0, true ) 
        end 
    end 
) 
  
addCommandHandler ( "info", 
    function ( player ) 
        if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( aclGroupInfo ) ) ) then 
            local veh = getPedOccupiedVehicle ( player ) 
            if ( veh ) then 
                if ( isCarPrivate ( veh ) ) then 
                    outputChatBox ( "Model tego pojazdu to:".. getElementModel ( veh ) .. ", wlascicielem jest: " .. getPrivateCarOwner ( veh ) .. ".", player, 255, 255, 255, true ) 
                else 
                    outputChatBox ( "To nie jest prywatne auto.", player, 255, 255, 255, true ) 
                end 
            end 
        else 
            outputChatBox ( "Nie masz uprawnień do tego!", player, 255, 0, 0, true ) 
        end 
    end 
) 
  
addEventHandler ( "onVehicleStartEnter", root, 
    function ( player, seat ) 
        if ( isCarPrivate ( source ) ) then 
            if ( seat == 0 ) then 
                local account = getPlayerAccount ( player ) 
                if ( not isGuestAccount ( account ) ) then 
                    local accName = getAccountName ( account ) 
                    local carAccountName = getPrivateCarOwner ( source ) 
                    if ( accName ~= carAccountName ) then 
                        cancelEvent ( ) 
                        outputChatBox ( "Nie posiadasz Klucza do tego auta!", player, 255, 0, 0, true ) 
                    else 
                        setElementFrozen ( source, false ) 
                    end 
                else 
                    cancelEvent ( ) 
                    outputChatBox ( "Nie posiadasz Klucza do tego auta!", player, 255, 0, 0, true ) 
                end 
            end 
        end 
    end 
) 
  
addEventHandler ( "onVehicleExit", root, 
    function ( player, seat ) 
        if ( isCarPrivate ( source ) ) then 
            if ( seat == 0 ) then 
                local account = getPlayerAccount ( player ) 
                if ( not isGuestAccount ( account ) ) then 
                    local accName = getAccountName ( account ) 
                    local carAccountName = getPrivateCarOwner ( source ) 
                    if ( accName == carAccountName ) then 
                        setElementFrozen ( source, true ) 
                    end 
                end 
            end 
        end 
    end 
)  
  

,,NIE WAŻNE JAK UPADASZ WAŻNE JEST JAK SIĘ PODNOSISZ.''

Posted

Bardzo chetnie ale nie w tym momencie korzystam teraz z tableta więc raczej szanse są zerowe na tą chwilę.

,,NIE WAŻNE JAK UPADASZ WAŻNE JEST JAK SIĘ PODNOSISZ.''

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