Jump to content

Tema pasado


Plate

Recommended Posts

Hola recuerdan mi intento de systema de resets bueno la cosa es haci puse esto

exports [ "scoreboard" ]:scoreboardAddColumn ( "reset" ) 
function reset (thePlayer, command) 
 exports [ "exp_system" ]:setPlayerEXP (thePlayer, 0) 
   exports [ "exp_system" ]:setPlayerLevel (thePlayer, 1) 
   setElementData(thePlayer,"reset",0) 
end 
  
addCommandHandler ("Reset", reset ) 

y hasta hay me funciono osea el player resetea y le aparece el 0 pero cuando vuelve a resetear no funciona

Algo qe me puedan decir hacerca de esto?

Link to comment

Facil:

exports [ "scoreboard" ]:scoreboardAddColumn ( "reset" ) 
function reset (thePlayer, command) 
 exports [ "exp_system" ]:setPlayerEXP (thePlayer, 0) 
   exports [ "exp_system" ]:setPlayerLevel (thePlayer, 1) 
local res = getElementData(thePlayer, reset) 
    if res >= 0 then 
   setElementData(thePlayer,"reset", res + 1) 
elseif not res then 
setElementData(thePlayer,"reset", 1) 
    end 
end 
addCommandHandler ("Reset", reset ) 

Link to comment

Note algo, intenta asi:

exports [ "scoreboard" ]:scoreboardAddColumn ( "reset" ) 
function reset (thePlayer, command) 
 exports [ "exp_system" ]:setPlayerEXP (thePlayer, 0) 
   exports [ "exp_system" ]:setPlayerLevel (thePlayer, 1) 
local res = getElementData(thePlayer, "reset") 
   setElementData(thePlayer,"reset", res + 1) 
    end 
addCommandHandler ("Reset", reset ) 
  
function respawn ( ) 
setElementData(source,"reset", "0") 
addEventHandler ( "onPlayerJoin", getRootElement(), respawn ) 

pero mejor usa los Account Data

Edited by Guest
Link to comment
exports [ "scoreboard" ]:scoreboardAddColumn ( "reset" ) 
  
function reset ( thePlayer ) 
    exports [ "exp_system" ]:setPlayerEXP ( thePlayer, 0 ) 
    exports [ "exp_system" ]:setPlayerLevel ( thePlayer, 1 ) 
    local res = tonumber ( getElementData ( thePlayer, "reset" ) ) or 0 
    setElementData ( thePlayer, "reset", res + 1 ) 
end 
addCommandHandler ( "Reset", reset ) 
  
function respawn ( ) 
    setElementData ( source, "reset", 0 ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), respawn ) 

Acordate de que es server side.

Link to comment

listo nose por que pero empeso a andar :D gracias solid y alex

para poner que el player pueda resetear a un cierto level tendria que ser haci no miren

exports [ "scoreboard" ]:scoreboardAddColumn ( "reset" ) 
  
function reset ( thePlayer ) 
    exports [ "exp_system" ]:setPlayerEXP ( thePlayer, 0 ) 
    exports [ "exp_system" ]:setPlayerLevel ( thePlayer, 1 ) 
    exports [ "exp_system" ]:getPlayerLevel ( thePlayer, 32 ) 
    local res = tonumber ( getElementData ( thePlayer, "reset" ) ) or 0 
    setElementData ( thePlayer, "reset", res + 1 ) 
end 
addCommandHandler ( "Reset", reset ) 
  
function respawn ( ) 
    setElementData ( source, "reset", 0 ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), respawn ) 

haci o esta mal hay

Link to comment

No, el getPlayerLvl no posee ese argumento, es asi:

exports [ "scoreboard" ]:scoreboardAddColumn ( "reset" ) 
  
function reset ( thePlayer ) 
    exports [ "exp_system" ]:setPlayerEXP ( thePlayer, 0 ) 
    exports [ "exp_system" ]:setPlayerLevel ( thePlayer, 32 ) 
    exports [ "exp_system" ]:getPlayerLevel ( thePlayer ) 
    local res = tonumber ( getElementData ( thePlayer, "reset" ) ) or 0 
    setElementData ( thePlayer, "reset", res + 1 ) 
end 
addCommandHandler ( "Reset", reset ) 
  
function respawn ( ) 
    setElementData ( source, "reset", 0 ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), respawn ) 

Link to comment

Pense que es lo que buscabas, como pusiste un 32 en el get o quiza quieres quieres que solo pueda seteat al estar en lvl 32, para eso usa:

exports [ "scoreboard" ]:scoreboardAddColumn ( "reset" ) 
  
function reset ( thePlayer ) 
local actlvl = exports [ "exp_system" ]:getPlayerLevel ( thePlayer ) 
                if actlvl >= 32 then --Asi solo podran setear en lvl 32 o mayor 
    exports [ "exp_system" ]:setPlayerEXP ( thePlayer, 0 ) 
    exports [ "exp_system" ]:setPlayerLevel ( thePlayer, 1 ) 
    local res = tonumber ( getElementData ( thePlayer, "reset" ) ) or 0 
    setElementData ( thePlayer, "reset", res + 1 ) 
    end 
end 
addCommandHandler ( "Reset", reset ) 
  
function respawn ( ) 
    setElementData ( source, "reset", 0 ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), respawn ) 

Link to comment

GRACIAS

saben encontre un recurso que esta muy bueno pero en el spotmanager tiene bug de

setElementData, getElementData 

--[[ 
/************************************************************** 
* 
* Script: Spot Management System 
* File: manager_server.lua 
* Version: 1.0.0 R3 
* Date: 2012-05-26 
* 
***************************************************************/ 
--]] 
  
if not getResourceFromName("zombies") then return end 
  
local RADIUS = 10 
local COUNT = 0 
local SPOT = { } 
local ZOMBIESINSPOT = { } 
  
function setRadius(source,command,radius) 
    if command == "setradius" then 
        if not radius then return false end 
        RADIUS = tonumber(radius) 
        outputChatBox("You have set spot radius to " .. RADIUS,source) 
        playSoundFrontEnd(source,41) 
    end 
end 
addCommandHandler("setradius",setRadius) 
  
function setCSPOT(source,command,spot) 
    if command == "setcurrentspot" then 
        if not spot then return false end 
        currentSpot = tonumber(spot) 
        outputChatBox("You have set current spot to spot[" .. spot .. "]",source) 
        playSoundFrontEnd(source,41) 
    end 
end 
addCommandHandler("setcurrentspot",setCSPOT) 
  
function addZombieToSpot(source,command,spot,rot,skin,interior, dimension, level, maxhealth, boss) 
    if command == "addzombie" then 
        if not spot then return false end 
        if not rot then 
        rot = math.random (1,359) 
        end 
        if not skin then skin = 0 end 
        if not interior then interior = 0 end 
        if not dimension then dimension = 0 end 
        if not level then level = 1 end 
        if not maxhealth then maxhealth = 100 end 
        if not boss then boss = false end 
        currentSpot = tonumber(spot) 
        local sx,sy,sz = getElementPosition(SPOT[currentSpot]) 
        local sortZombies = RADIUS/1.2 
        local zom = exports.zombies:createZombie (sx+math.random(-sortZombies,sortZombies),sy+math.random(-sortZombies,sortZombies),sz+10,rot,skin,interior,dimension,level,maxhealth,boss) 
        table.insert(ZOMBIESINSPOT,zom) 
        setElementData(zom,"zombieSpot",SPOT[currentSpot]) 
        outputChatBox("You have added '" .. getElementData(zom,"name") .. "' to spot[" .. spot .. "]",source) 
        playSoundFrontEnd(source,41) 
    end 
end 
addCommandHandler("addzombie",addZombieToSpot) 
  
-- ADD ZOMBIE GUI 
  
addEvent("addz",true) 
function addZgui(isboss,skin,interior,dimension,level,maxhp,name) 
    if skin and interior and dimension and level and maxhp then 
    rot = math.random (1,359) 
    local sx,sy,sz = getElementPosition(SPOT[currentSpot]) 
    local sortZombies = RADIUS/1.2 
    local zom = exports.zombies:createZombie (sx+math.random(-sortZombies,sortZombies),sy+math.random(-sortZombies,sortZombies),sz+10,rot,skin,interior,dimension,level,maxhp,isboss) 
    table.insert(ZOMBIESINSPOT,zom) 
    setElementData(zom,"zombieSpot",SPOT[currentSpot]) 
        if name == "" then 
        outputChatBox("You have added '" .. getElementData(zom,"name") .. "' to spot[" .. currentSpot .. "]",source) 
        else 
        outputChatBox("You have added '" .. name .. "' to spot[" .. currentSpot .. "]",source) 
        setElementData(zom,"name",name) 
        end 
    end 
end 
addEventHandler( "addz", root, addZgui ) 
  
function destroySpot(source,command,spotToDestroy) 
    if command == "destroyspot" then 
        if currentSpot then 
            if not spotToDestroy then spotToDestroy = currentSpot; currentSpotElem = SPOT[currentSpot] end 
            local currentSpotElem = SPOT[tonumber(spotToDestroy)] 
            if currentSpotElem and spotToDestroy then 
                destroyElement(currentSpotElem) 
                table.remove(SPOT,spotToDestroy) 
                COUNT = COUNT - 1 
                outputChatBox("You have destroyed SPOT[" .. spotToDestroy .. "]",source) 
                playSoundFrontEnd(source,41) 
            else 
                outputChatBox("SPOT[" .. spotToDestroy .. "] doesnt exist.",source) 
                playSoundFrontEnd(source,41) 
            end 
        end 
    end 
end 
addCommandHandler("destroyspot",destroySpot) 
  
function outputClick(mouseButton,buttonState,clickedElement,worldPosX,worldPosY,worldPosZ,screenPosX,screenPosY) 
    if mouseButton == "right" and buttonState == "down" then 
        local file = fileOpen("spots.lua",false) 
        fileSetPos(file,fileGetSize(file)) 
        COUNT = COUNT + 1 
        local written = fileWrite( file, '\n\r\nspot[' .. COUNT .. '] = createZombieSpot(' .. worldPosX .. ", " .. worldPosY .. ", " .. worldPosZ .. ", " .. RADIUS .. " )\r\n" ) 
            if written then 
                outputChatBox("You have created SPOT[" .. COUNT .. "]",source) 
                playSoundFrontEnd(source,41) 
            end 
        --SPOT[COUNT] = createColSphere(worldPosX,worldPosY,worldPosZ,RADIUS) 
        SPOT[COUNT],radius = exports.zombies:createZombieSpot(worldPosX,worldPosY,worldPosZ,RADIUS) 
        setElementData(SPOT[COUNT],"radius",radius) 
        --setElementData(SPOT[COUNT],"count",COUNT) 
        currentSpot = COUNT 
        fileFlush(file) 
    end 
end 
addEventHandler("onPlayerClick",getRootElement(),outputClick) 
  
function markSpot() 
    local spot = SPOT 
    local currentspot = currentSpot 
    local zombiesinspot = ZOMBIESINSPOT 
    triggerClientEvent("markSpotC",root,spot,currentspot,zombiesinspot) 
end 
setTimer(markSpot,50,0) 
  
--DESTROYS CREATED ZOMBIES BY SPOT MANAGER 
function Zomb_delete (ped) 
    if isElement(ped) then 
        if (getElementData (ped, "zombie") == true) then 
            for theKey,thePed in ipairs(ZOMBIESINSPOT) do 
                if ped == thePed then 
                    table.remove( ZOMBIESINSPOT, theKey ) 
                    break 
                end 
            end 
            destroyElement ( ped ) 
        end 
    end 
end 
  
addEventHandler ( "onResourceStop", getResourceRootElement(getThisResource()),  
function ( ) 
    for k,zombie in ipairs(ZOMBIESINSPOT) do 
        --table.remove( ZOMBIESINSPOT, k ) 
        Zomb_delete(zombie) 
    end 
end  
) 
  
  

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...