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

Wysłany: 2019-01-02, 19:49


HeviK*







Wiek: 29
Na forum: 3016 dni
Posty: 34

Piwa: 2

Respekt: 40,5

Witam, chcia? bym ustawi? graczowi exp komend? i zrobi?em ju? system exp, ?e gdy zabije zombie to dostaje exp itp.

function systemEXP(playerxp)
    local account getPlayerAccount(player);
    local eksp2getAccountData(account"exp") or 0;
    local ekspeksp2xp;
    setAccountData(account"exp"eksp);
    setElementData(player"exp"eksp);
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-02, 20:05


Atroth







Wiek: 23
Na forum: 3677 dni
Posty: 1089
Nick w MP: Atroth

Piwa: 4808

Respekt: 540
Respekt: 540

HeviK*, mo?esz rozwin?? swoj? my?l, co chcesz osi?gn?? bo nic mi nie m?wi co Ty chcesz.

Podpis

Użytkownik - 10-05-2016
Support Team - 17.06.2017
Moderator - 25.11.2017
Mod-Team - 02.07.2018

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-02, 20:10


HeviK*







Wiek: 29
Na forum: 3016 dni
Posty: 34

Piwa: 2

Respekt: 40,5

Chodzi mi o to, ?e wpisz? komende /setxp nick gracza, ilosc xp.
Chc? ustawia? komu? xp poprzez komend?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-02, 20:36


Eitho







Wiek: 24
Na forum: 3489 dni
Posty: 330
Nick w MP: Eitho

Piwa: 746

Respekt: 256,5
Respekt: 256,5Respekt: 256,5Respekt: 256,5

Moja propozycja:
function systemEXP(playerxp)
    local account getPlayerAccount(player);
    local eksp2getAccountData(account"exp") or 0;
    local ekspeksp2xp;
    setAccountData(account"exp"eksp);
    setElementData(player"exp"eksp);
end
------------------------------------------

function setXP(playerxp)
    if not player or not xp then
        return false
    end
    local account getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
    if not account then
        return false
    end
    setAccountData(account'exp'xp)
    if getPlayerFromName(playerthen
        setElementData(getPlayerFromName(player), 'exp'tonumber(xp))
    end
    return true
end

function giveXP(playergivexp)
    if not player or not givexp then
        return false
    end
    local account getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
    if not account then
        return false
    end
    local xp getAccountData(account'exp') or 0
    setAccountData(account'exp'xp+givexp)
    if getPlayerFromName(playerthen
        setElementData(getPlayerFromName(player), 'exp'xp+givexp)
    end
    return true
end

function takeXP(playertakexp)
    if not player or not takexp then
        return false
    end
    local account getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
    if not account then
        return false
    end
    local xp getAccountData(account'exp') or 0
    setAccountData(account'exp'xp-takexp)
    if getPlayerFromName(playerthen
        setElementData(getPlayerFromName(player), 'exp'xp-takexp)
    end
    return true
end

addCommandHandler('setXP', function(plrcmdtargetPlayerxp)
    setXP(targetPlayerxp)
end)

addCommandHandler('giveXP', function(plrcmdtargetPlayerxp)
    giveXP(targetPlayerxp)
end)

addCommandHandler('takeXP', function(plrcmdtargetPlayerxp)
    takeXP(targetPlayerxp)
end)


Powinno dzia?a? bez wzgl?du czy gracz jest online czy nie, nie testowane.
Edit: testowane, poprawione

Podpis
good old days :]
Ostatnio zmieniony przez Eitho 2019-01-03, 22:46, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-02, 20:38


Mikołajj







Wiek: 22
Na forum: 2885 dni
Posty: 303
Nick w MP: Mikołaj

Piwa: 132

Respekt: 91


addCommandHandler("setxp", function(plrexp)
    setAccountData(getPlayerAccount(plr), "exp"exp)
    setElementData(plr"exp"exp)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-03, 20:30


Atroth







Wiek: 23
Na forum: 3677 dni
Posty: 1089
Nick w MP: Atroth

Piwa: 4808

Respekt: 540
Respekt: 540

Eitho, po co tworzysz funkcj? skoro od razu mo?na j? da? w eventHandlerze :-?

HeviK*,


addCommandHandler("setXP",function(sourcePlayer,cmd,player,xp)
if player and xp then
local target getPlayerFromName(player);
if target then 
setAccountData(target"exp"xp);
setElementData(target"exp"xp);
outputChatBox("Ustawiono "..xp.." punkt?w XP graczowi "..player,sourcePlayer);
else
outputChatBox("Nie znaleziono gracza!",sourcePlayer);
end
else
outputChatBox("Nie poda?e? nicku gracza lub punkt?w do?wiadczenia!",sourcePlayer);
end
end)


Podpis

Użytkownik - 10-05-2016
Support Team - 17.06.2017
Moderator - 25.11.2017
Mod-Team - 02.07.2018

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-03, 20:46


Eitho







Wiek: 24
Na forum: 3489 dni
Posty: 330
Nick w MP: Eitho

Piwa: 746

Respekt: 256,5
Respekt: 256,5Respekt: 256,5Respekt: 256,5

"Atroth" napisał/a:

Eitho, po co tworzysz funkcj? skoro od razu mo?na j? da? w eventHandlerze :-?

HeviK*,


addCommandHandler("setXP",function(sourcePlayer,cmd,player,xp)
if player and xp then
local target getPlayerFromName(player);
if target then 
setAccountData(target"exp"xp);
setElementData(target"exp"xp);
outputChatBox("Ustawiono "..xp.." punkt?w XP graczowi "..player,sourcePlayer);
else
outputChatBox("Nie znaleziono gracza!",sourcePlayer);
end
else
outputChatBox("Nie poda?e? nicku gracza lub punkt?w do?wiadczenia!",sourcePlayer);
end
end)

Po to, ?e je?li jest osobno to tych funkcji mo?e sobie u?ywa? nadal w jakich? innych skryptach, skoro robi sw?j system xp.

Podpis
good old days :]
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-03, 21:18


HeviK*







Wiek: 29
Na forum: 3016 dni
Posty: 34

Piwa: 2

Respekt: 40,5

"Atroth" napisał/a:

Eitho, po co tworzysz funkcj? skoro od razu mo?na j? da? w eventHandlerze :-?

HeviK*,


addCommandHandler("setXP",function(sourcePlayer,cmd,player,xp)
if player and xp then
local target getPlayerFromName(player);
if target then 
setAccountData(target"exp"xp);
setElementData(target"exp"xp);
outputChatBox("Ustawiono "..xp.." punkt?w XP graczowi "..player,sourcePlayer);
else
outputChatBox("Nie znaleziono gracza!",sourcePlayer);
end
else
outputChatBox("Nie poda?e? nicku gracza lub punkt?w do?wiadczenia!",sourcePlayer);
end
end)

Komenda dzia?a i przyznaje xp, ale nie zapisuje go :/

[ Dodano: 2019-01-03, 21:21 ]
"Eitho" napisał/a:

Moja propozycja:
function systemEXP(playerxp)
    local account getPlayerAccount(player);
    local eksp2getAccountData(account"exp") or 0;
    local ekspeksp2xp;
    setAccountData(account"exp"eksp);
    setElementData(player"exp"eksp);
end
------------------------------------------

function setXP(playerxp)
    if not player or not xp then
        return false
    end
    local account getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
    if not account then
        return false
    end
    setAccountData(account'exp'xp)
    if getPlayerFromName(playerthen
        setElementData(player'exp'xp)
    end
    return true
end

function giveXP(playergivexp)
    if not player or not givexp then
        return false
    end
    local account getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
    if not account then
        return false
    end
    local xp getAccountData(account'exp') or 0
    setAccountData(account'exp'xp+givexp)
    if getPlayerFromName(playerthen
        setElementData(player'exp'xp+givexp)
    end
    return true
end

function takeXP(playertakexp)
    if not player or not takexp then
        return false
    end
    local account getPlayerFromName(player) and getPlayerAccount(getPlayerFromName(player)) or getAccount(player)
    if not account then
        return false
    end
    local xp getAccountData(account'exp') or 0
    setAccountData(account'exp'xp-takexp)
    if getPlayerFromName(playerthen
        setElementData(player'exp'xp-takexp)
    end
    return true
end

addCommandHandler('setXP', function(plrcmdtargetPlayerxp)
    setXP(targetPlayerxp)
end)

addCommandHandler('giveXP', function(plrcmdtargetPlayerxp)
    giveXP(targetPlayerxp)
end)

addCommandHandler('takeXP', function(plrcmdtargetPlayerxp)
    takeXP(targetPlayerxp)
end)

Powinno dzia?a? bez wzgl?du czy gracz jest online czy nie, nie testowane.

Wywala mi b??d, ?e nie wyszukuje mi argumentu 1, czyli /setXP NICK, XP (nicku nie wyszukuje)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-03, 21:33


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

HeviK*, to ju? problem le?y po twojej stronie - nie masz zapisu exp

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-03, 22:00


HeviK*







Wiek: 29
Na forum: 3016 dni
Posty: 34

Piwa: 2

Respekt: 40,5

addEventHandler("onPlayerLogin"root, function()
        local acc getPlayerAccount(source);
        setElementData(source"exp"getAccountData(acc"exp") or 0);
    end);

Zapis by?, tylko nie podawalem go. Je?li ustawie komenda /setXP to ustawi mi xp ale jak zabije np zombie to przed ustawieniem mialem 10 xp ustawie 20 i zabije zombie to jest 11 (za zabicie jest +1)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-04, 07:49


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Poka? kod, kt?rym dodajesz EXP po zabiciu zombie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-01-04, 10:18


HeviK*







Wiek: 29
Na forum: 3016 dni
Posty: 34

Piwa: 2

Respekt: 40,5

"Wilq" napisał/a:

Poka? kod, kt?rym dodajesz EXP po zabiciu zombie.

Na samej gorze masz
 systemEXP(killer1)
Tak dodalem do kodu swojego ( killer to osoba zabijajaca zombie a drugi argument to ilosc xp za 1 zombie.)

Postaw piwo autorowi tego posta
 

 
Tagi: komenda :: parametrami
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