-
Posts
75 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Infinity#
-
http://sarsrpg.us/forums/topic/7-updates-information/?page=2 Trying our hardest to bring daily updates to the server. Check out the link.
-
That is as simple as it can be. Its just that on client, all the tables aren't quite necessary because its only made for the client that is calling the function. On server, it calls for everyone, so you've to make it specifically for the player who called it. Hence the tables made, backpack[player] and hat[player], etc. Forgot to mention, try the script, I'm sure it'll work.
-
Your file is on client side. Change it to server side. On your meta.xml change it to. <script src="server.lua" type="server"/> server.lua local backpack = {} local hat = {} function attachBackpackAndHatToPlayer(player) if isElement(player) and getElementType(player) == "player" then if isElement(backpack[player]) and isElement(hat[player]) then destroyElement(backpack[player]) backpack[player] = nil destroyElement(hat[player]) hat[player] = nil else local resource = getResourceFromName("bone_attach") -- returns the resource named bone_attach -- local state = getResourceState(resource) -- checks the resource status -- if tostring(state) == "running" then -- checks if the bone_attach resource is running to continue -- backpack[player] = createObject(371, 0, 0, -111) hat[player] = createObject(954, 0, 0, -111) exports.bone_attach:attachElementToBone(backpack[player], player, 3, 0, -0.15, -0.0, 0, 0, 0) exports.bone_attach:attachElementToBone(hat[player], player, 1, 0, 0.05, -0.56, 0, 0, 0) else outputChatBox("Ask an admin to start the 'bone_attach' resource to use this command.", player, 0, 255, 0, false) end end end end addCommandHandler("backpack", attachBackpackAndHatToPlayer)
-
addCommandHandler("deposit", function(player, command, money) if player and command and tonumber(money) then local amount = math.ceil(tonumber(money)) if tonumber(amount) > 0 then exports["rc_core"]:getMoney(player) >= amount then exports["rc_core"]:takeMoney(player, amount) giveBankMoney(player, amount) else outputChatBox("Not enough money to make this transaction.", player, 177, 9, 45, false) end else outputChatBox("Syntax: /deposit amount", player, 177, 9, 45, false) end end) Enjoy. Made few changes to the rest of the lines, personally, I like to be very organized whilst making scripts so I'll be able to read them very well. I added on the line to check if the player, command and the 'value' for 'money' exists, to continue. The 'value' for 'money' must be a number or it won't continue, fixing your 'number expected, got string' problem. Now it'll expect a number all the times.
-
Topic fully updated. Took my time to fully describe every little detail about the server. There's a lot more to come soon. Server still up and running. Feel free to join us anytime at mtasa://79.137.33.163:9905. We've a Discord server up and running at https://discord.gg/kwKX3VR. Also, our login panel has been updated & bugs have been fixed. We currently have 659 accounts. (This is a legit number due to the system we've only allowing you to create/have one account linked to your serial) "Playing as a Civilian" section being written. A civilian job pack is being worked on and it'll be live on the server when its fully done. That is why there is no civilian section as of right now.
-
Thank you for reporting this. I confirmed the bug myself and I'll be working on it. We appreciate it.
-
Latest updates on the server. Possibility to spawn at owned properties & sell vehicles in-game. Also, new spawn panel design.
-
We're more than proud to announce that we're daily reaching to 50+ players. That's a huge success in my book. Latest activity. (Today)
-
Clan recruitment is opened. http://sarsrpg.us/index.php?/forum/12-sars-clan-recruitment/ We're looking forward to recruiting people into the clan. To keep up with the server updates, visit this topic. http://sarsrpg.us/index.php?/topic/7-updates-information/
-
Thank you for visiting, hope you visit more often and thank you for the awesome feedback :D.
-
New screenshots added.
-
Like I said on our forums, hope you enjoy
-
f
-
Put this line inside your custom name tag script. if getElementAlpha(element) == 0 then return end If it doesn't work, put your client-side file below (optional) and I'll help.
-
Online players: setElementData(getPlayerFromName("playerName"), "myZom", amount) -- To update the current data setAccountData(getPlayerAccount(getPlayerFromName("playerName")), "myZom", amount) -- To make sure the data saves upon disconnection Offline players: setAccountData(getAccount("accountName"), "myZom", amount) -- To change the data from an offline account Or instead of using the run code command, you can use this instead. -- /setonlinekills playerName newKills -- Online command function changeOnlineData(player, command, name, amount) if player and command and name then local account = getAccountName(getPlayerAccount(player)) if account and isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then if getPlayerFromPartialName(name) then local nameElement = getPlayerFromPartialName(name) local nameAccount = getPlayerAccount(nameElement) setElementData(nameElement, "myZomb", amount) setAccountData(nameAccount, "myZomb", amount) outputChatBox("".. getPlayerName(nameElement) .." kills has been set to ".. amount ..".", player, 0, 200, 0, false) end end end end addCommandHandler("setonlinekills", changeOnlineData) -- /setofflinekills accountName newKills -- Offline command function changeOfflineData(player, command, name, amount) if player and command and name then local account = getAccountName(getPlayerAccount(player)) if account and isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then if getAccount(name) then local nameAccount = getAccount(name) setAccountData(nameAccount, "myZomb", amount) outputChatBox("".. name .." kills has been set to ".. amount ..".", player, 0, 200, 0, false) end end end end addCommandHandler("setofflinekills", changeOfflineData) function getPlayerFromPartialName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end
-
Client local owner = nil local ped = nil local animation = false function followPed() if (not isElement(owner) or not isElement(ped)) then return end if (isPedInVehicle(ped)) then return end if animation == false then local cX, cY = getElementPosition(owner) local pX, pY = getElementPosition(ped) local copangle = (360 - math.deg(math.atan2((cX - pX), (cY - pY)))) % 360 setPedRotation(ped, copangle) setElementInterior(ped, getElementInterior(owner)) setElementDimension(ped, getElementDimension(owner)) local dist = getDistanceBetweenPoints2D(cX, cY, pX, pY) if (dist > 16) then -- Warp local x, y, z = getElementPosition(owner) setElementPosition(ped, x, y, z) animation = true setTimer(function() animation = false end, 1000, 1) elseif (dist > 6) then -- Sprint setPedAnimation(ped, "PED", "sprint_civi") animation = true setTimer(function() animation = false end, 1000, 1) elseif (dist > 4) then -- Jog setPedAnimation(ped, "PED", "JOG_maleA") animation = true setTimer(function() animation = false end, 1000, 1) elseif (dist > 1.5) then -- Walk setPedAnimation(ped, "PED", "WALK_civi") animation = true setTimer(function() animation = false end, 1000, 1) elseif (dist <= 2) then -- Stop setPedAnimation(ped, "PED", "IDLE_stance") animation = true setTimer(function() animation = false end, 1000, 1) end end end function triggerFollow(element, creator) ped = element owner = creator removeEventHandler("onClientRender", getRootElement(), followPed) addEventHandler("onClientRender", getRootElement(), followPed) end addEvent("triggerFollow", true) addEventHandler("triggerFollow", getRootElement(), triggerFollow) Server local peds = {} function pedCreation(thePlayer, command, skin) if not isElement(peds[thePlayer]) then if thePlayer and isElement(thePlayer) and getElementType(thePlayer) == "player" then local x, y, z = getElementPosition(thePlayer) local _, _, r = getElementRotation(thePlayer) if x and y and z then if not skin then skin = 139 end peds[thePlayer] = createPed(skin, x, y, z, r, false) if peds[thePlayer] then outputChatBox("You have successfully created a ped. (ID: ".. skin ..")", thePlayer, 0, 200, 0, false) triggerClientEvent(thePlayer, "triggerFollow", getRootElement(), peds[thePlayer], thePlayer) else outputChatBox("Invalid Skin ID.", thePlayer, 200, 0, 0, false) end end end else outputChatBox("Use /dPed to remove the existing Ped.", thePlayer, 200, 0, 0, false) end end addCommandHandler("cPed", pedCreation) function pedDestroy(thePlayer) if isElement(peds[thePlayer]) then destroyElement(peds[thePlayer]) peds[thePlayer] = nil outputChatBox("You have successfully deleted the ped.", thePlayer, 0, 255, 0, false) else outputChatBox("Create a ped with /cPed <id>", thePlayer, 0, 200, 0, false) end end addCommandHandler("dPed", pedDestroy) function pedDestroyQuit() if isElement(peds[source]) then destroyElement(peds[source]) peds[source] = nil end end addEventHandler("onPlayerQuit", getRootElement(), pedDestroyQuit) El unico problema es que los demas no pueden ver cuando se mueve. Voy a tratar de hacerte algo mejor. Pero usa este por ahora.
-
From what I have read, you're trying to make it so players can only create one NPC ped so it doesn't cause lag. Easy. I also made it possible (optional) for them to create their own Ped skin ID, it can be optionally inserted. If "skin" isn't inserted, it'll be '139' (ID) by default. Ped is also created on the creator's rotation. Only 1 ped can be created, made a function where the creator of the ped can delete the ped with /dPed and ped is deleted upon creator's disconnection. local peds = {} function pedCreation(thePlayer, command, skin) if not isElement(peds[thePlayer]) then if thePlayer and isElement(thePlayer) and getElementType(thePlayer) == "player" then local x, y, z = getElementPosition(thePlayer) local _, _, r = getElementRotation(thePlayer) if x and y and z then if not skin then skin = 139 end peds[thePlayer] = createPed(skin, x, y, z, r, false) if peds[thePlayer] then outputChatBox("You have successfully created a ped. (ID: ".. skin ..")", thePlayer, 0, 200, 0, false) else outputChatBox("Invalid Skin ID.", thePlayer, 200, 0, 0, false) end end end else outputChatBox("Use /dPed to remove the existing Ped.", thePlayer, 200, 0, 0, false) end end addCommandHandler("cPed", pedCreation) function pedDestroy(thePlayer) if isElement(peds[thePlayer]) then destroyElement(peds[thePlayer]) peds[thePlayer] = nil outputChatBox("You have successfully deleted the ped.", thePlayer, 0, 255, 0, false) else outputChatBox("Create a ped with /cPed <id>", thePlayer, 0, 200, 0, false) end end addCommandHandler("dPed", pedDestroy) function pedDestroyQuit() if isElement(peds[source]) then destroyElement(peds[source]) peds[source] = nil end end addEventHandler("onPlayerQuit", getRootElement(), pedDestroyQuit) Si necesitas algo mas, me dejas saber.
-
Also, I noticed something. Do you have a separate spawning system? Because if you do, I would understand. But upon player joining the game, if they aren't being spawned from another script, then it should be doing it from this one. Let me know
-
You can't enable commands on custom chats. You'll have to do it separately. Since you made a custom chat box, it won't work. As far as I know, "/" commands only work using "T."
-
function loadAccounts() if source then local serial = getPlayerSerial(source) local result = dbQuery(database, "SELECT * FROM accounts WHERE serial = ?", serial) if result then local row = dbPoll(result) setElementPosition(source, row.x, row.y, row.z) setElementInterior(source, row.intterior) setElementDimension(source, row.demension) setElementModel(source, row.skin) setElementHealth(source, row.health) setPedArmor(source, row.armor) setPlayerWantedLevel(source, row.wanted) setPlayerTeam(source, row.team) local poll, rows = dbPoll(result, -1) if rows == 1 then setPlayerMoney(source, poll[1]["money"]) end end end end addEventHandler("onPlayerJoin", getRootElement(), loadAccounts) addEventHandler("onPlayerQuit", getRootElement(), saveAccounts) Try this.
-
function disableCommand(command) if command == "me" then cancelEvent() end end addEventHandler("onPlayerCommand", root, disableCommand) This should definitely work.