Jump to content

[HELP] Please


1LoL1

Recommended Posts

Hello, i created script but not work can anyone please fix my code?

I mean when seconds in ban is "0" so data will +1 and when ban will normal so data2 will +1.

function WwW (player, seconds, data, additional) 
if (seconds) == 0 then 
setElementData(player, "Data", (getElementData(player, "Data") or 0) + 1) -- Permanent ban 
else 
setElementData(player, "Data2", (getElementData(player, "Data2") or 0) + 1) -- Other Ban 
end 
end 
addEventHandler ( "onPlayerBan", getRootElement(), WwW) 

Link to comment
The element data will directly be removed after the player is banned... It will not even synchronized with the other players in the server because it is a slow transfer.

But i have save system on Data and Data2 i want to only when player is banned and seconds is 0 so he get data +1 if seconds > 1 so he get data2 +1

Link to comment
  • Moderators

But your main problem is that 'onPlayerBan' doesn't support: seconds, data, additional

Only the banPointer and it's responsibleElement.

Use ban functions instead:

function WwW (banPointer, responsibleElement) 
local player = source -- The player that gets banned. 
local seconds = getBanTime(banPointer) - getRealTime().timestamp 

Link to comment
But your main problem is that 'onPlayerBan' doesn't support: seconds, data, additional

Only the banPointer and it's responsibleElement.

Use ban functions instead:

function WwW (banPointer, responsibleElement) 
local player = source -- The player that gets banned. 
local seconds = getBanTime(banPointer) - getRealTime().timestamp 

So this?

function WwW (banPointer, responsibleElement) 
local player = source 
local seconds = getBanTime(banPointer) - getRealTime().timestamp 
if (seconds) == 0 then 
setElementData(player, "Data", (getElementData(player, "Data") or 0) + 1) 
else 
setElementData(player, "Data2", (getElementData(player, "Data2") or 0) + 1) 
end 
end 
addEventHandler ( "onPlayerBan", getRootElement(), WwW ) 

Link to comment
  • Moderators

No, I don't think so. Because the real time never stops, while the ban time is static.

function WwW (banPointer, responsibleElement) 
    local player = source 
    local banTime = getBanTime(banPointer) 
    if not banTime then -- ban time isn't specific, so perma ban. 
        setElementData(player, "Data", (getElementData(player, "Data") or 0) + 1) 
    else 
        --local seconds = banTime - getRealTime().timestamp 
        setElementData(player, "Data2", (getElementData(player, "Data2") or 0) + 1) 
    end 
end 
addEventHandler ( "onPlayerBan", getRootElement(), WwW ) 

Link to comment
No, I don't think so. Because the real time never stops, while the ban time is static.
function WwW (banPointer, responsibleElement) 
    local player = source 
    local banTime = getBanTime(banPointer) 
    if not banTime then -- ban time isn't specific, so perma ban. 
        setElementData(player, "Data", (getElementData(player, "Data") or 0) + 1) 
    else 
        --local seconds = banTime - getRealTime().timestamp 
        setElementData(player, "Data2", (getElementData(player, "Data2") or 0) + 1) 
    end 
end 
addEventHandler ( "onPlayerBan", getRootElement(), WwW ) 

Not work :( now when i banned player so he have 2x Data2 and 0X Data

Link to comment
  • 4 weeks later...

Anyone help please? :(

function Bans (banPointer, responsibleElement) 
    local player = source 
    local bt = getBanTime(banPointer) 
    if not bt then 
    setElementData(player, "Pbans", (getElementData(player, "Pbans") or 0) + 1) 
    elseif bt then 
    setElementData(player, "Bans", (getElementData(player, "Bans") or 0) + 1) 
    end 
end 
addEventHandler("onPlayerBan", getRootElement(), Bans) 

Link to comment
When a player disconnects, the player/ped element is destroyed, therefore all element data is deleted, therefore your code makes no sense — setting the element data of a player who was banned just before he/she is disconnected?

I have save on this. When player is kicked so he get + 1x "DATA" but i don't know how to define permanent ban and normally ban.

Link to comment

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