1LoL1 Posted November 21, 2015 Share Posted November 21, 2015 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
Moderators IIYAMA Posted November 21, 2015 Moderators Share Posted November 21, 2015 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. Link to comment
1LoL1 Posted November 21, 2015 Author Share Posted November 21, 2015 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 IIYAMA Posted November 21, 2015 Moderators Share Posted November 21, 2015 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
1LoL1 Posted November 21, 2015 Author Share Posted November 21, 2015 But your main problem is that 'onPlayerBan' doesn't support: seconds, data, additionalOnly 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 IIYAMA Posted November 21, 2015 Moderators Share Posted November 21, 2015 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
1LoL1 Posted November 21, 2015 Author Share Posted November 21, 2015 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 Data Link to comment
Moderators IIYAMA Posted November 21, 2015 Moderators Share Posted November 21, 2015 debug the variable banTime... if you want to know which condition you have to use. Link to comment
1LoL1 Posted December 16, 2015 Author Share Posted December 16, 2015 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
Addlibs Posted December 17, 2015 Share Posted December 17, 2015 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? Link to comment
1LoL1 Posted December 17, 2015 Author Share Posted December 17, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now