-
Posts
21,935 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Castillo
-
actually i never tryed this gui classes O_o, i ever used guieditor
-
here is done and working admins.lua admins = "" function processAdminList() players = getElementsByType ( "player" ) admins = "" for k,v in ipairs(players) do local accountname = "" if (isGuestAccount(getPlayerAccount(v)) == false) then accountname = getAccountName (getPlayerAccount(v)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then if (admins == "") then admins = getPlayerName(v) else admins = admins .. ", " .. getPlayerName(v) end end end end outputChatBox( "Online Admins:", getRootElement(), 255, 255, 0) outputChatBox( " " .. tostring ( admins ), getRootElement(), 255, 255, 0) end addEvent("admins", true) addEventHandler( "admins",getRootElement(), processAdminList ) --addCommandHandler ( "admins", processAdminList ) function checkCommand ( message, messageType ) if ( messageType == 0 ) then if ( message == "!admins" ) then setTimer( triggerEvent, 100, 1, "admins", source ) end end end addEventHandler ( "onPlayerChat", getRootElement(), checkCommand ) meta.xml <meta> <info name="online admins" author="Castillo" version="1.0" type="script" /> <script src="admins.lua" type="server"/> meta>
-
server.lua addEvent("onPlayerDestructionDerbyWin",true) addEventHandler("onPlayerDestructionDerbyWin",getRootElement(), function (winner) givePlayerMoney(winner, 1200) outputChatBox(getPlayerName ( winner ) .. " has won $1200 as last player alive",getRootElement(),0,255,0) end) meta.xml <meta> <info author="Castillo" description="Price for winning a race" type="script" version="1.0" /> <script src="server.lua" type="server"/> meta> i guess u understand a litle more now
-
addEvent("onPlayerDestructionDerbyWin",true) addEventHandler("onPlayerDestructionDerbyWin",getRootElement(), function (winner) givePlayerMoney(winner, 1200) outputChatBox(getPlayerName ( winner ) .. " has won $1200 as last player alive",getRootElement(),0,255,0) end)
-
i guess this is what u wanted. addEvent("onPlayerDestructionDerbyWin",true) addEventHandler("onPlayerDestructionDerbyWin",getRootElement(), function ( ) local veh = getPedOccupiedVehicle(winner) if veh then setVehicleFrozen ( veh, true, not isVehicleFrozen ( veh) ) end end)
-
this is weird, never happend to me b4, im trying many things and nothing works
-
I dont see the point of this topic i vote for lock
-
i installed it and now dosnt even save his current You can get all player weapons in client-side script and send them to the server with triggerServerEvent or you can use setElementData which can sync the data but is unsafe. well, a friend had this script using account data and worked all saving all without a client part so ?
-
i installed it and now dosnt even save his current
-
getPlayerWeapon has the 'slot' parameter server side only in 1.0.4 MTA version. I guess you are using an older version, so this function takes only current weapon. oh i see, then if i use a 1.0.4 version beta will work?
-
but still not saving all or loading them...
-
this works but itsnt saving all weapons only saves player current weapon not all slots
-
no problem, and remember to start to learn!!!
-
im sorry but u stealed this from ESPORTs race server and dont start to lie cause i was in that server some days ago so fuck off and stop stealing
-
ok, but it gives a error when trying to give weapon weapon.lua: Bad argument @ "giveWeapon" - Line: 35
-
well, i made it for you but you must know that i wont make anything u post here so start to learn by yourself client side: GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(161,102,390,342,"Buy window",false) GUIEditor_Button[1] = guiCreateButton(31,25,90,18,"Buy nitro",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(30,46,91,17,"Buy repair",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(131,25,209,50,"Press Buy nitro to buy a niro\nPress buy repair to buy a repair",false,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1], false) function guiToggleVisible ( ) if ( guiGetVisible ( GUIEditor_Window[1] ) == true ) then guiSetVisible(GUIEditor_Window[1], false) showCursor ( false ) else guiSetVisible(GUIEditor_Window[1], true) showCursor ( true ) end end bindKey ( "M", "down", guiToggleVisible ) function fixv() triggerServerEvent("fixRequest", getLocalPlayer()) end addEventHandler("onClientGUIClick",GUIEditor_Button[2],fixv,false) function nitro() triggerServerEvent("nitro", getLocalPlayer()) end addEventHandler("onClientGUIClick",GUIEditor_Button[1],nitro,false) server side: addEvent("nitro", true) addEventHandler("nitro", getRootElement(), function() if isPedInVehicle(source) then if ( getPlayerMoney (source) >= 7000 ) then takePlayerMoney(source, 7000) addVehicleUpgrade(getPedOccupiedVehicle(source),1010) outputChatBox("Nitro Successfully added", source, 255, 255, 0, true) else outputChatBox("Not enough money.", source, 255, 0, 0, true) end else outputChatBox("You are not in a vehicle", source, 255, 0, 0, true) end end ) addEvent("fixRequest", true) addEventHandler("fixRequest", getRootElement(), function() if isPedInVehicle(source) then if ( getPlayerMoney (source) >= 20000 ) then takePlayerMoney(source, 20000) fixVehicle(getPedOccupiedVehicle(source)) outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true) else outputChatBox("Not enough money.", source, 255, 0, 0, true) end else outputChatBox("You are not in a vehicle", source, 255, 0, 0, true) end end )
-
but the save weapon part is it fine or is buggi? the code should look like this then? local slotT = "slot" local ammoT = "ammo" function start () executeSQLCreateTable(slotT, "accountname TEXT, slot INT") executeSQLCreateTable(ammoT, "accountname TEXT, ammo INT") outputDebugString ( "Resource loaded.", 3 ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), start) function savePlayerData() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then local i = 0 for i < 13 do local temp = getPlayerWeapon(source, i) executeSQLUpdate(slotT, "slot = '"..temp.."'", "accountname = '"..getAccountName(acc).."'") local temp2 = getPlayerTotalAmmo(source, i) executeSQLUpdate(ammoT, "ammo = '"..temp2.."'", "accountname = '"..getAccountName(acc).."'") i = i +1 end end end addEventHandler("onPlayerQuit", getRootElement(), savePlayerData) addEventHandler("onPlayerLogout", getRootElement(), savePlayerData) addEventHandler("onPlayerWasted", getRootElement(), savePlayerData) function login1(prev, account, autologin) local account = getPlayerAccount(source) local result = executeSQLQuery("SELECT slot FROM slot WHERE accountname='" .. getAccountName(account) .. "'") local result2 = executeSQLQuery("SELECT ammo FROM ammo WHERE accountname='" .. getAccountName(account) .. "'") if result and #result > 0 then --giveWeapon(source, result, result2) giveWeapon(source, result, tonumber(result2)) end outputDebugString(tostring(executeSQLInsert(slotT, "'0', '"..getAccountName(account).."'", "slot, accountname"))) outputDebugString(tostring(executeSQLInsert(ammoT, "'0', '"..getAccountName(account).."'", "ammo, accountname"))) end addEventHandler("onPlayerLogin", getRootElement(), login1) addEventHandler("onPlayerSpawn", getRootElement(), login1)
-
well, u have to script this so i recomend to start to learn how to script and make it by yourself
-
wtf u mean with this????
-
hey, i want to save player weapons,ammo in sqlite and then when he logins in he will get them back, here is my code so far. local slotT = "slot" local ammoT = "ammo" function start () executeSQLCreateTable(slotT, "accountname TEXT, slot INT") executeSQLCreateTable(ammoT, "accountname TEXT, ammo INT") outputDebugString ( "Resource loaded.", 3 ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), start) function savePlayerData() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then local i = 0 while i < 13 do local temp = getPlayerWeapon(source, i) executeSQLUpdate(slotT, "slot = '"..temp.."'", "accountname = '"..getAccountName(acc).."'") local temp2 = getPlayerTotalAmmo(source, i) executeSQLUpdate(ammoT, "ammo = '"..temp2.."'", "accountname = '"..getAccountName(acc).."'") i = i +1 end end end addEventHandler("onPlayerQuit", getRootElement(), savePlayerData) addEventHandler("onPlayerLogout", getRootElement(), savePlayerData) addEventHandler("onPlayerWasted", getRootElement(), savePlayerData) function login1(prev, account, autologin) local account = getPlayerAccount(source) local result = executeSQLQuery("SELECT slot FROM slot WHERE accountname='" .. getAccountName(account) .. "'") local result2 = executeSQLQuery("SELECT ammo FROM ammo WHERE accountname='" .. getAccountName(account) .. "'") if result and #result > 0 then --giveWeapon(source, result, result2) giveWeapon(source, result, tonumber(result2)) end outputDebugString(tostring(executeSQLInsert(slotT, "'0', '"..getAccountName(account).."'", "slot, accountname"))) outputDebugString(tostring(executeSQLInsert(ammoT, "'0', '"..getAccountName(account).."'", "ammo, accountname"))) end addEventHandler("onPlayerLogin", getRootElement(), login1) addEventHandler("onPlayerSpawn", getRootElement(), login1) btw this code is creating somthing called ERROR: ERROR: Infinite/too long execution (weapon) ERROR: Aborting; infinite running script
-
lol just copy and paste my code in a client.lua and a server.lua cause karlis is meaning other thing.
-
client: local root = getRootElement() local player = getLocalPlayer() local counter = 0 local starttick local currenttick addEventHandler("onClientRender",root, function() if not starttick then starttick = getTickCount() end counter = counter + 1 currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(player,"money",getPlayerMoney(player) ) counter = 0 starttick = false end end server: addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() call(getResourceFromName("scoreboard"),"addScoreboardColumn","money") end )
-
what u talking about? there is no video if im not wrong
