-
Posts
156 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Ayush Rathore
-
Where is getdatax in the scripts and btw why you used it for all players as it would increase performance and takes more memory and laggs addEventHandler("onElementDataChange",getRootElement(), function (dataName,getdatax) if getElementType(source) == "player" then local player = source if dataName == "points" then if getdatax >= 10000 then setElementData(player,"Rank","Novice") elseif getdatax >= 100000 then setElementData(player,"Rank","Active") elseif getdatax >= 1000000 then setElementData(player,"Rank","Scholar") elseif getdatax >= 10000000 then setElementData(player,"Rank","Master") end end end)
-
Can't copy database.db file to database_backup
Ayush Rathore replied to RobbyAJM's topic in Scripting
you are welcome -
use this x,y = guiGetScreenSize() GUIEditor = { edit = {}, button = {}, window = {}, label = {}, radiobutton = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(x/2-248/2, y/2-284/2, 248, 284, "", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.88) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF000000") GUIEditor.button[1] = guiCreateButton(0.14, 0.79, 0.71, 0.18, "Purchase Dog", true, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(0.03, 0.13, 0.92, 0.10, "Dog Creator", true, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "center") GUIEditor.label[2] = guiCreateLabel(0.05, 0.29, 0.24, 0.10, "Name:", true, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[2], "center") GUIEditor.label[3] = guiCreateLabel(0.05, 0.40, 0.24, 0.10, "Breed:", true, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[3], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[3], "center") GUIEditor.label[4] = guiCreateLabel(0.05, 0.52, 0.24, 0.10, "Color:", true, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[4], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[4], "center") GUIEditor.radiobutton[1] = guiCreateRadioButton(0.34, 0.68, 0.15, 0.06, "M", true, GUIEditor.window[1]) GUIEditor.radiobutton[2] = guiCreateRadioButton(0.53, 0.68, 0.15, 0.06, "F", true, GUIEditor.window[1]) guiRadioButtonSetSelected(GUIEditor.radiobutton[2], true) GUIEditor.edit[1] = guiCreateEdit(0.38, 0.29, 0.53, 0.08, "", true, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(0.38, 0.39, 0.53, 0.08, "", true, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(0.38, 0.50, 0.53, 0.08, "", true, GUIEditor.window[1]) end )
-
pickup weapon when button pressed inside of marker
Ayush Rathore replied to kewizzle's topic in Scripting
outputServerLog ( "***Drop System Loaded ***" ) local state = {} local function bindState(player) bindKey(player, "f", "down", function(player) if isElement(getElementData(player,"pickup")) then usePickup(getElementData(player,"pickup"),player) removeElementData(player,"pickup") end end) end function getElementsWithinMarker(marker) if (not isElement(marker) or getElementType(marker) ~= "marker") then return false end local markerColShape = getElementColShape(marker) local elements = getElementsWithinColShape(markerColShape) return elements end addEventHandler("onResourceStart", resourceRoot, function() for _, player in pairs(getElementsByType ("player")) do bindState(player) end end) addEventHandler("onPlayerJoin", root, function() bindState(source) end) function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies if ( killer ) then if ( getElementType ( killer ) == "player" ) then x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z dropped = createPickup ( x, y, z, 2, math.random(22, 34), 15000, math.random(1,3)) dropmarker = createMarker ( x, y, z-0.5, "cylinder", 1, math.random(1, 255), math.random(1, 255), math.random(1, 255), 255) addEventHandler("onMarkerHit", dropmarker, function(player) if isElement(player) and getElementType(player) == 'player' then setElementData(player,"pickup",dropped) end end) setTimer(destroyElement, 15000, 1, dropped) setTimer(destroyElement, 15000, 1, dropmarker) end end end addEventHandler("onPedWasted", getRootElement(), createDeathPickup) try this my bad -
wait i will give you how to do that
-
function getPlayerID(player) if player then local theid players = getElementsByType("player") for id,p in ipairs(players) do if player == p then theid = id end end return theid else return false end end function getPlayerFromID(theID) if theID then theID = tonumber(theID) local theplayer players = getElementsByType("player") for id,p in ipairs(players) do if theID == id then theplayer = p end end return theplayer else return false end end function privateMessage(thePlayer, commandName, sendToName, ...) local message = table.concat({...}, " ") local toPlayer = getPlayerFromPartialName(sendToName) or getPlayerFromID(sendToName) if toPlayer then local pmblocked = getElementData(toPlayer, "pmblocked") if toPlayer ~= thePlayer then if pmblocked ~= 1 then if message ~= "" then outputChatBox("PM to "..getPlayerName(toPlayer).."("..getPlayerID(toPlayer)..") : "..message, thePlayer, 238, 232, 84) outputChatBox("PM from "..getPlayerName(thePlayer).."("..getPlayerID(thePlayer)..") : "..message, toPlayer, 236, 205, 45) outputServerLog("PM to "..getPlayerName(toPlayer).."("..getPlayerID(toPlayer)..") : "..message) outputServerLog("PM from "..getPlayerName(thePlayer).."("..getPlayerID(thePlayer)..") : "..message) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) end else outputChatBox("This person has diasble his pm try later!", thePlayer, 255, 0, 0) end else outputChatBox("You can't speak to yourself!", thePlayer, 255, 0, 0) end else outputChatBox("Player not found!", thePlayer, 255, 0, 0) end end addCommandHandler("pm", privateMessage) now try
-
pickup weapon when button pressed inside of marker
Ayush Rathore replied to kewizzle's topic in Scripting
Try this outputServerLog ( "***Drop System Loaded ***" ) local state = {} local function bindState(player) bindKey(player, "f", "down", function(player) if isElement(getElementData(player,"pickup")) then usePickup(getElementData(player,"pickup"),player) removeElementData(player,"pickup") end end) end function getElementsWithinMarker(marker) if (not isElement(marker) or getElementType(marker) ~= "marker") then return false end local markerColShape = getElementColShape(marker) local elements = getElementsWithinColShape(markerColShape) return elements end addEventHandler("onResourceStart", resourceRoot, function() for _, player in pairs(getElementsByType ("player")) do bindState(player) end end) addEventHandler("onPlayerJoin", root, function() bindState(source) end) function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies if ( killer ) then if ( getElementType ( killer ) == "player" ) then x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z dropped = createPickup ( x, y, z, 2, math.random(22, 34), 15000, math.random(1,3)) dropmarker = createMarker ( x, y, z-0.5, "cylinder", 1, math.random(1, 255), math.random(1, 255), math.random(1, 255), 255) addEventHandler("onMarkerHit", dropmarker, function(player) if isElement(player) and getElementType(player) = 'player' then setElementData(player,"pickup",dropped) end end) setTimer(destroyElement, 15000, 1, dropped) setTimer(destroyElement, 15000, 1, dropmarker) end end end addEventHandler("onPedWasted", getRootElement(), createDeathPickup) -
Hi have you said this to me or the post owner☺
-
use this local dbConnection = dbConnect("sqlite", "backupexprank.db") local qh = dbQuery( dbConnection,"CREATE TABLE IF NOT EXISTS accounts (nomeconta STRING,patente STRING,experiencia STRING)") dbFree( qh ) function saveStat(sourcePlayer) local account = getPlayerAccount(sourcePlayer) local nomeconta = getAccountName(account) local patente = getAccountData(account, "password") local experiencia = getAccountData(account, "ip") local qh = dbQuery( dbConnection, "SELECT * FROM accounts where nomeconta=?",nomeconta) local res = dbPoll(qh,-1) dbFree( qh ) if #res > 0 then dbExec( dbConnection, "UPDATE accounts SET experiencia=? where nomeconta=? ", experiencia,nomeconta ) dbExec( dbConnection, "UPDATE accounts SET patente=? where nomeconta=? ", patente,nomeconta ) else dbExec(dbConnection, "INSERT INTO accounts VALUES(?, ?, ?)", nomeconta, patente, experiencia) end end addCommandHandler("savestats", saveStat) Be sure to add in account data ip and password enjoy
-
this might fix it exports.scoreboard:addScoreboardColumn("playtime") local ptimer = {} function playtime() for i,player in ipairs(getElementsByType("player")) do if ptimer[player] then ptimer[player] = ptimer[player] + 1 setElementData(player,"playtime",math.floor(ptimer[player]/3600).." hr") end end end setTimer(playtime,1000,0) function dependent(player) local accountName = getAccountName ( getPlayerAccount ( player ) ) local hour = (tonumber(getAccountData ( getPlayerAccount ( player ), "hour")) or 0)/3600 if hour >= 30 then if aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..accountName) == true then redirectPlayer(player,"",0) else outputChatBox("You are now in group SuperModerator",player) end end end addEventHandler("onPlayerLogin", root, function() dependent(source) ptimer[source] = (tonumber(getAccountData ( getPlayerAccount ( source ), "hour")) or 0) end) addEventHandler("onPlayerLogout", root,function(account) if ptimer[source] then setAccountData( account , "hour" , math.floor(ptimer[source]) ) ptimer[source] = nil end end) well my script is a whole package of of what you want just remove other timer resource and use this but make sure this code needs acl right to perform tasks and also remove if aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..accountName) == true then with if aclGroupAddObject (aclGetGroup("Dependent"), "user."..accountName) == true then enjoy and good luck
-
Can't copy database.db file to database_backup
Ayush Rathore replied to RobbyAJM's topic in Scripting
well it also worked for me wait till the post owner reply -
Can't copy database.db file to database_backup
Ayush Rathore replied to RobbyAJM's topic in Scripting
well it does not matter the file is being used or not you cannot delete but u can copy, Think of it as coping a gta.exe when its running but you cannot delete it local bsaved = false local timer = nil function baseCopy() local randomName = "" local time = getRealTime() local second = time.second local minute = time.minute local hour = time.hour local monthday = time.monthday local month = time.month local year = time.year local res = getResourceName(getThisResource()) local pathtocopy = ":dayz/database_backup/"..monthday.."."..month + 1 ..".".. year + 1900 .."_"..hour.."."..minute.."."..second.."_"..randomName..".db" if fileCopy(":dayz/database.db",pathtocopy) then outputDebugString("database saved") end end addCommandHandler("backupmydata",basecopy) function checkforNoPlayers() if getPlayerCount() == 0 and bsaved == false then baseCopy() bsaved = true killTimer(timer) end end addEventHandler("onResourceStart",root,function(res) if res == getThisResource() then timer = setTimer(checkforNoPlayers,1000,0) outputDebugString("timer for saving created") end end) addEventHandler("onPlayerJoin",root,function() if isTimer(timer) then outputDebugString("timer for saving already exists") else bsaved = false timer = setTimer(checkforNoPlayers,1000,0) outputDebugString("timer for saving created") end end) well you should use it when all the players are disconnected as it would lead to data loss if you copy while player is playing as query could be running use this above code of mine it will automatically save you data when a player count = 0 and if you want it to be forced use /backupmydata in console -
any Help?
-
Well i was making this code but its not working properly. Client Side local weapa local weapb function mini_front() local che = getPedOccupiedVehicle(getLocalPlayer()) x,y,z = getElementPosition(getLocalPlayer()) if che then weapa = createWeapon("minigun",x,y,z) weapb = createWeapon("minigun",x,y,z) setElementAlpha(weapa,0) attachElements(weapa,che,-1.18,1.9,-0.6, 0, 0, 90) setElementAlpha(weapb,0) attachElements(weapb,che,1.18,1.9,-0.6, 0, 0, 90) setWeaponClipAmmo(weapb, 99999) setWeaponClipAmmo(weapa, 99999) setWeaponState(weapa,"firing") setWeaponState(weapb,"firing") end end function mini_front_stop() if isElement(weapa) and isElement(weapb) then destroyElement(weapa) destroyElement(weapb) end end addEvent("mini_front",true) addEventHandler("mini_front",getLocalPlayer(),mini_front) addEvent("mini_front_stop",true) addEventHandler("mini_front_stop",getLocalPlayer(),mini_front_stop) Server Side function minigun_front(source) triggerClientEvent(root,"mini_front",source) end function minigun_front_stop(source) triggerClientEvent(root,"mini_front_stop",source) end function rocket_white(source) bindKey(source,'mouse1','down',minigun_front) bindKey(source,'mouse1','down',minigun_front_stop) end addEventHandler("onVehicleEnter", root, rocket_white) The code works fine but the only error is that only local player can see it and it also do not cause any damage (server/client both) Thanks for help in Advance.
-
Well no. may be you should ask more experienced scripters.
-
well you should change the name of your id resource '-' in your resource name is causing trouble or change this line to exports.id-system:getPlayerFromID(tonumber(sendToName)) to exports["id-system"]:getPlayerFromID(tonumber(sendToName)) Well when i tested on my server it worked fine
-
Event System - PLEASE I'M ALL THE DAY TRYING TO MAKE THIS
Ayush Rathore replied to Gabriel1375's topic in Scripting
Loki look in wiki well it happens to everyone it will be this local items = { {"Banana"}, {"Kiwi"}, {"Pizza"} } function fimdoevento(_,killer) if getElementType(killer) == "player" and getElementData(source,"eventoblip") == true then -- checks if the killer is a player we dont want cars to get the item ._. and if the player killed has the event blip. local item = items[math.random(#items)][1]-- get random table entry. local quantity = math.random(5) -- generate random quantity between 1-5 destroyElement(blip)-- destroy the blip setElementData(source, "eventoblip",false)-- remove the event data from the admin setElementData(killer, "Sniper Rifle Ammo", 150)-- give the killer(player who killed the admin) Sniper ammo outputChatBox ('#00a5ff==============================================================',root,255,255,255,true) outputChatBox ("#00a5ff Congratulations [#FF0000" ..getPlayerName(killer).."#00a5ff] win a [#ff0000 "..quantity.."x "..item.."#00a5ff]!",root,255,255,255,true)-- output messaage with the killer's name outputChatBox ('#00a5ff==============================================================',root,255,255,255,true) end end addEventHandler("onPlayerWasted", root, fimdoevento) use this -
My bad i just copied Papeles code sorry .
-
may be that server is running on an highly configured vps or host as i only know about unoccupied_vehicle_sync_interval setting and in my opinion that's the only way of achieving it
-
Thanks
-
well whats the error ? what you mean by lagged?
-
do this local serial = {} serial["your serial"] = true serial["ypur serial"] = true function checkConnectingSerial( nick, ip, ser, iVersion, sVersion ) if not serial[ser] then cancelEvent( true, "Invalid serial number." ) end end addEventHandler( "onPlayerConnect", root, checkConnectingSerial )
-
ok no problem
-
do u mean my post tell me
