Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2017-01-21, 12:14


dida102

LUA To moja Pasja






Wiek: 25
Na forum: 3753 dni
Posty: 86
Nick w MP: Remi

Piwa: 642

Respekt: 20

Ostrzeżeń: 100%
Siema Mam Paczke Your Adwenture I nie Mg Da? se premium pisze /dajvipa Remi 1 I nie daje A dm Nie Moge szuszark? ruszy? Dam kodzik
- Przy kazdym wejsciu i wyjsciu ustawia maksymalna liczbe slotow na ilosc aktualnych graczy + 10% z maksymalnej ilosci slotow, zrobione przez Bone

function dynamiczne()
local maks_graczy = getServerConfigSetting ( "maxplayers" )
local teraz_graczy = #getElementsByType( "player" )
local nowe = math.ceil( teraz_graczy + (tonumber(maks_graczy) * 0.2) )
if tonumber(nowe) < tonumber(maks_graczy) then
setMaxPlayers(nowe)
else
setMaxPlayers(tonumber(maks_graczy))
end
end

addEventHandler("onPlayerQuit",root,dynamiczne)
addEventHandler("onPlayerJoin",root,dynamiczne)

--[[addEventHandler("onPlayerConnect", getRootElement(), function (nick, ip, username, serial)
    local q = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_serials WHERE serial=?", serial)
    if #q < 1 then
        cancelEvent(true, "Nie jeste? zautoryzowany do wej?cia na ten serwer !") 
    end
end)--]]

addEvent("core:spawnPlayer", true)
addEventHandler("core:spawnPlayer", root, function()
    local pos=getElementData(source,"player:spawn")
    if not pos then return end
    fadeCamera(source, true)
    spawnPlayer(source, pos[1], pos[2], pos[3])
    setCameraTarget(source,source)
    toggleControl(source,"fire", false)
    toggleControl(source,"aim_weapon", false)
    local load=loadPlayerData(source)
    if load then outputChatBox("* Pomy?lnie wczytano Twoje dane, ?yczymy mi?ej gry.",source) end
    setElementData(source,'HS_accountName',getPlayerName(source));
    setElementData(source,"player:online",0)
    if getElementData(source,"player:premium") then 
        local queryA=string.format("SELECT * FROM ogrpg_users WHERE id=%d AND premiumdate>NOW() LIMIT 1", getElementData(source,"player:uid"))
        local resultA=exports["ogrpg-db"]:dbSet(queryA)
        if (queryA) then
            --outputChatBox("* Konto premium wa?ne do " ..queryA["premiumdate"], source)
            outputChatBox("* Posiadasz aktywne konto premium do " .. queryA["premiumdate"] .. ".", source, 255, 200, 0)
        end
        local v2=exports['ogrpg-db']:dbGet('SELECT * FROM ogrpg_users WHERE premium=?')
        for ile,_ in ipairs(v2) do
            ilosc = ile
        end
        outputChatBox("* Aktualnie posiadamy "..ilosc.." kont(a/o) ze statusem PREMIUM, dzi?kujemy za wsparcie!", client, 255, 255, 255)
    end
    triggerClientEvent(source,"core:blipyaut",root,source)
end)

setTimer(function()
    local players=getElementsByType('player')
    for _, p in pairs(players) do
            if getElementData(p, "player:online") and tonumber(getElementData(p, "player:online")) > 60 then
                if getElementData(p, "player:online") == 60 then
                    local hour = getElementData(localPlayer,"player:hours") or 0
                    setElementData(localPlayer,"player:hours",hour+1)
                end 
                setElementData(p, "player:online", 0)
                if getElementData(p, "player:premium") then
                triggerEvent("givePlayerMoney", p, 10000, false)
                outputChatBox("* Premium: Otrzymujesz 10000 PLN za przegranie 1h na serwerze.", p)
            end
        end
     end
end, 60000, 0)

addEventHandler("onPlayerWasted", root, function()
    plr=source
    if getElementData(plr,"player:job") then
        triggerClientEvent(plr,"onFinish", root, plr)
        setElementData(plr,"player:job", false)
    end
    setTimer(function()
        local pos=getElementData(plr,"player:spawn")
        if not pos then return end
        fadeCamera(plr, true)
        setElementInterior(plr,0)
        setElementDimension(plr,0)
        spawnPlayer(plr, pos[1], pos[2], pos[3])
        setCameraTarget(plr, plr)
        setElementModel(plr, getElementData(plr, "player:skin"))
    end, 60, 1)
end)

addEvent("giveSpray", true)
addEvent("takeSpray", true)
addEventHandler("giveSpray", root, function()
    giveWeapon ( source, 41, 200 )
end)

addEvent("givecamera", true)
addEventHandler("givecamera", root, function()
    giveWeapon ( source, 43, 99999999 )
end)

addEventHandler("takeSpray", root, function()
    takeWeapon ( source, 41)
end)

addCommandHandler("frr", function(playerSource )
    local pos=getElementData(playerSource ,"player:spawn")
    if not pos then return end
    fadeCamera(playerSource , true)
    setElementInterior(playerSource ,0)
    setElementDimension(playerSource,0)
    setElementPosition(playerSource , pos[1], pos[2], pos[3])
    setCameraTarget(playerSource,playerSource )
    setElementModel(playerSource, getElementData(playerSource , "player:skin"))
end)

addEventHandler("onPlayerConnect", root, function(playerNick)
    if string.find(playerNick, "#") ~= nil or string.find(playerNick, "?") ~= nil or string.find(playerNick, "!") ~= nil then
        cancelEvent(true,"Tw?j nick zawiera jeden z niedozwolonych znak?w(#,?,!), zmie? go.")
    end
end)

addEventHandler('onPlayerConnect', root, function(playerNick, playerIP, playerUsername, playerSerial)
    local result=exports['ogrpg-db']:dbGet('SELECT * FROM ogrpg_ban WHERE active=1 AND serial=? AND time>NOW() LIMIT 1;', playerSerial)
    if #result > 0 then
        cancelEvent(true,"Zosta?e?(a?) zbanowany(a) na tym serwerze!\nPow?d zbanowania:" .. result[1].reason.."\nCzas bana:"..result[1].time.."\nOd kary mo?esz zaapelowa? na mta-yblife.cba.pl")
    else
        exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_ban WHERE type=? AND active=1 AND serial=?", "ban", playerSerial)
    end
end)

addEventHandler("onPlayerJoin", root, function()
    outputChatBox("* Witaj "..getPlayerName(source).." na Polski Serwer RPG.", source)
    outputChatBox("* Je?eli jeste? tu po raz pierwszy zajrzyj pod F1!",source)
    outputChatBox("* Znajdziesz tam szczeg??owy poradnik.", source)
end)

 addCommandHandler("closehud", function(plr,cmd)
    setElementData(plr,"notshowhud",not getElementData(plr,"notshowhud"))
 end)


addEventHandler("onResourceStart", resourceRoot, function()
    setWaveHeight(2)
    setMinuteDuration(6000)
    setMapName("RPG**DYNAMICZNE SLOTY**")
    setGameType("RPG**DYNAMICZNE SLOTY**")
end)


addEventHandler("onPlayerChangeNick", root, function() cancelEvent() end)
addEventHandler("onResourceStart", root, function() 
local players=getElementsByType('player')
for _, p in pairs(players) do
--bindKey(p, "y", "down", "chatbox", "global")
end
end)

setTimer(function()
    local vehicles=getElementsByType('vehicle')
    for _, vehicle in pairs(vehicles) do
        if getElementHealth(vehicle)<300 then
            setVehicleDamageProof(vehicle, true)
        elseif getElementHealth(vehicle)>301 then
            if getVehicleController (vehicle) then
            setVehicleDamageProof(vehicle, false)
            end
        end
     end
end, 500, 0)

setTimer(function()
  for i,v in ipairs(getElementsByType("player")) do
    if not getElementData(v,"player:spawn") then return end
    if isPedDead(v) then
        local pos=getElementData(v,"player:spawn")
        fadeCamera(v, true)
        setElementInterior(v,0)
        setElementDimension(v,0)
        spawnPlayer(v, pos[1], pos[2], pos[3])
        setCameraTarget(v, plr)
        setElementModel(v, getElementData(plr, "player:skin"))
    end
    if( getPlayerIdleTime(v) > 1 ) then
    setElementData(v, "player:afk", true)
    elseif ( getPlayerIdleTime(v) < 1 ) then
    setElementData(v, "player:afk", false)
    end    
  end
end, 10000, 0)




--[[
Obsluga oswietlenia drogowego
@author Lukasz Biegaj <wielebny@bestplay.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
]]--



setTrafficLightsLocked(true)

-- 3 1 0 4

local stany={3,4,0,1}

local stan=1

local stany_nocne={6,9,6,9}

function zmianaSwiatel()
    stan=stan+1
    if (stan>#stany) then stan=1 end

    local h,m=getTime()
    if (h>=23 or m<=6) then
        setTrafficLightState(stany_nocne[stan])
        setTimer(zmianaSwiatel, 500, 1)
    else
        setTrafficLightState(stany[stan])
        setTimer(zmianaSwiatel, stan%2==1 and 15000 or 2000, 1)

    end

end


zmianaSwiatel()


Komentarz marcin778 dodany 2017-01-21, 12:20Używaj znaczniki [lua][/lua]
Ostatnio zmieniony przez marcin778 2017-01-21, 12:19, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-01-21, 15:17


nanKy







Wiek: 23
Na forum: 4007 dni
Posty: 498
Nick w MP: nanky

Piwa: 1775

Respekt: 239
Respekt: 239Respekt: 239

Nie masz komendy na nadawanie premium znajduje si? ona w ogrpg-gui>s_pgui.lua

Postaw piwo autorowi tego posta
 

 
Tagi: premium
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku