myonlake
Members-
Posts
2,312 -
Joined
-
Days Won
40
Everything posted by myonlake
-
I have rElement defined like this earlier in the script: local rElement = getRootElement() Aww, :O, I just saw that this script effects on EVERY car. "five" is the thing I will put here: /issuekey playername five
-
Hello again, I have a problem with issuing someone a car key. It seems to work just fine. I can give him a key, it saves the key, everything is normal. Now, when he goes inside the car, which has the same key than the player, he still can't drive the car. Don't take notice about the findPlayer() thing, I've got a seperate script for it and it works. I gave the player a key: "five", the vehicle has "five" too... function issueKey(player, cmd, name, key) local target = findPlayer(name, player) if hasObjectPermissionTo(player, "command.ban") then if target then if key then setElementData(target, "sfserver.carkey", key) outputChatBox("* " .. getPlayerName(player) .. " issued you a car key (ID: " .. key .. ")", target, 0, 255, 0, false) outputChatBox("* You have issued " .. getPlayerName(target) .. " a car key (ID: " .. key .. ")", player, 0, 255, 0, false) else outputChatBox("* Syntax: /issuekey ", player, 220, 220, 0, false) end else outputChatBox("* No player found.", player, 255, 0, 0, false) end else outputChatBox("* You must be an administrator to use this command.", player, 255, 0, 0, false) end end addCommandHandler("issuekey", issueKey) function cars() local car_1 = createVehicle(587, -2270, 2392, 5) setElementData(car_1, "sfserver.carkey", five) end addEventHandler("onResourceStart", root, cars) function vehicleEnterKey(thePlayer) local theVehicle = getPedOccupiedVehicle(thePlayer) local boom1 = getElementData(thePlayer, "sfserver.carkey") local boom2 = getElementData(theVehicle, "sfserver.carkey") if boom1 == boom2 then else outputChatBox("* You don't own this vehicle!", thePlayer, 255, 0, 0, false) removePedFromVehicle(thePlayer) end end addEventHandler("onVehicleEnter", rElement, vehicleEnterKey)
-
Alright, I am doing this another way now. I have a command that spawns a car, the command gives me a data with math.random. It works normally. When I enter the car I spawned, it sets MY DATA into the car aswell, we both have identical DATA. When someone else does the command too, it works normally. When he enters my car, he SHOULD get ejected from the vehicle, but... unfortunatly he doesn't. What's wrong? function enterVehicle(thePlayer) local theVehicle = getPedOccupiedVehicle(thePlayer) local veh = getElementData(theVehicle, "sfserver.key") local pla = getElementData(thePlayer, "sfserver.key") if not getElementData(theVehicle, "sfserver.key") and getElementData(thePlayer, "sfserver.key") then setElementData(theVehicle, "sfserver.key", getElementData(thePlayer, "sfserver.key")) outputChatBox("Vehicle has now a key: " .. getElementData(thePlayer, "sfserver.key") .. ".", thePlayer, 0, 255, 0, false) elseif getElementData(theVehicle, "sfserver.key") and not veh == pla or not getElementData(thePlayer, "sfserver.key") then removePedFromVehicle(thePlayer) outputChatBox("You have an incorrect key, it means you don't own this vehicle.", thePlayer, 0, 255, 0, false) end end addEventHandler("onVehicleEnter", getRootElement(), enterVehicle)
-
If I do: local vehicle = createVehicle(id, x, y, z) It changes all the "vehicle"s data's, right?
-
So, I don't need to care about the createVehicle function? Usually we do "local theVehicle = createVeh.."
-
I am trying to do a vehicle key script. You spawn a vehicle, it has a key that you have too, if you don't have the same key, you won't be able to enter the vehicle, there is an example below, I didn't do the lock thing yet.. function createVehicle(thePlayer, cmd, id) local x, y, z = getElementPosition(thePlayer) if id then createVehicle(id, x, y, z) setElementData(theVehicle, "server.key", math.random(0, 1000)) setElementData(thePlayer, "server.key", getElementData(whathere, "server.key")) outputChatBox(getElementData(whathere, "server.key") .. " is the ID of the vehicle.", thePlayer, 255, 255, 255, false) else outputChatBox("Syntax: /cv ", thePlayer, 220, 220, 0, false) end end addCommandHandler("cv", createVehicle) function enterVehicle(thePlayer) local theVehicle = getPedOccupiedVehicle(thePlayer) if not getElementData(theVehicle, "server.key") == getElementData(thePlayer, "server.key") then outputChatBox("Incorrect key", thePlayer, 255, 0, 0, false) end end addEventHandler("onVehicleEnter", getRootElement(), enterVehicle)
-
Hello, I am just thinking that is it possible to make many cars via a command, then giving them all a different name. When I enter the car, I need to have the correct key for it. I have tried elementData, but it seems impossible, because... I have only one createVehicle. I dunno. function createVehicle(thePlayer, cmd, id) local x, y, z = getElementPosition(thePlayer) if id then createVehicle(id, x, y, z) setElementData(whathere, "server.key", math.random(0, 1000)) setElementData(thePlayer, "server.key", getElementData(whathere, "server.key")) outputChatBox(getElementData(whathere, "server.key") .. " is the ID of the vehicle.", thePlayer, 255, 255, 255, false) else outputChatBox("Syntax: /cv ", thePlayer, 220, 220, 0, false) end end addCommandHandler("cv", createVehicle) function enterVehicle(thePlayer) local theVehicle = getPedOccupiedVehicle(thePlayer) if not getElementData(whathere, "server.key") == getElementData(thePlayer, "server.key") then outputChatBox("Incorrect key", thePlayer, 255, 0, 0, false) end end addEventHandler("onVehicleEnter", getRootElement(), enterVehicle)
-
Oh, my god! It works! Thank you so much, mate
-
Hello, I am doing a fuel script, unfortunatly this repeats the timer2 after the fuel is 0 or less than 0. I want to kill the timer, I've tried killTimer in many ways, it says stack overflow.. Any other way than repeat until (this was infinite ring which caused the server to abort the script). Unless you find a way to do it properly. So the main problem is that it spams my chatbox with the "Your vehicle ran out of fuel!" and I guess it also spams the engine toggling. function setFuelOn(thePlayer) local theVehicle = getPedOccupiedVehicle(thePlayer) local get = getElementData(theVehicle, "sfserver.fuel") if get == 0 or get < 0 then setVehicleEngineState(theVehicle, false) outputChatBox("This vehicle does not have any fuel!", thePlayer, 255, 0, 0, false) else local timer1 = setTimer( function() setElementData(theVehicle, "sfserver.fuel", get - 1) end, 50, 0) local timer2 = setTimer( function() if get == 0 or get < 0 then setVehicleEngineState(theVehicle, false) outputChatBox("Your vehicle ran out of fuel!", thePlayer, 255, 0, 0, false) end end, 1000, 0) end end addEventHandler("onVehicleEnter", rElement, setFuelOn) This is just one piece of the code, this is the one which doensn't work. Thanks
-
Hello, This user in community (GooD1997), is uploading virus resources, for example that "hack another computer". And he also re-uploads others resources that he haven't got any permission and he is spamming them into the community by downloading a resource and then uploading it. Descriptions are usually bull:~: "aaaaaaaaaaaaaa", "bbbbbbbb". So, just suggesting that you would ban him and remove his resources.
-
Problem was already solved if you didn't know
-
Heh! Thank you! That would not work... setSoundMaxDistance is the distance of the sound, it doesn't effect, because I can hear the sound normally, others don't. By the events I did it
-
function example(hitElement) if hitElement then if getElementType(hitElement) == "player" then -- Stuff here end end end Should work just fine.
-
Hello, As you know, using addCommandHandler with playSound3D works just fine, BUT the problem is that others cannot hear it, what should I do else on the below script to make it work for everybody, not just for myself. -- Funny song function playSong1() local song1 = playSound3D("sounds/cool.mp3", -1491, 763, 9, false) setSoundVolume(song1, 0.7) setSoundMaxDistance(song1, 100) end addCommandHandler("cool", playSong1) I have tried timers too but they didn't work either.
-
Why not just do Google search: "5 minutes to ms".
-
Hello, Is there any functions/events for that the server would get info that he is STILL loading, and when he has finished the files download, he would proceed to the main menu or spawn or anything that happens when loading is ended. Sorry for being such a... blind when scrolling the server/client functions/events list
-
Or then script some shaders like many servers do.
-
Help - Making script workes on player first time join
myonlake replied to SonicTHedgehog's topic in Scripting
get/setAccountData -
PlaySound is not the same as PlaySound3D. PlaySound does it globally, 3D does it locally. The problem in the script is that you don't have setSoundVolume there. Do this to get it working (client-side): function nHalt() local sound = playSound("sounds/Bus/nHalt.ogg") setSoundVolume(sound, 1.0) -- Valid: 0-1 end function lt() nHalt() local ltr = playSound("sounds/Bus/Bushaltestellen/LTR.ogg") setSoundVolume(ltr, 1.0) -- Valid: 0-1 end addEvent("LTR", true) addEventHandler("LTR", getRootElement(), lt) function SchrottP() nHalt() local schrott = playSound("sounds/Bus/Bushaltestellen/Schrott.ogg") setSoundVolume(schrott, 1.0) -- Valid: 0-1 end addEvent("Schrott", true) addEventHandler("Schrott", getRootElement(), SchrottP) function AngelP() nHalt() local angel = playSound("sounds/Bus/Bushaltestellen/Angel.ogg") setSoundVolume(angel, 1.0) -- Valid: 0-1 end addEvent("Angel", true) addEventHandler("Angel", getRootElement(), AngelP)
-
Well, functions to start with are.. createElement createRadarArea outputChatBox isObjectInACLGroup isInsideRadarArea
-
Yeah.. I know, but next time look the scripts yourself, even if the scripts are ours, you can fix them yourself too. And especially this happened because my script was working, and his weren't, before that you could of tested mine and his, see which one works and edit the scripts if you want to. EDIT: Hmm, hold on, I'll try to fix it.. EDIT 2: I really don't have to think about that bug, I hope someone fixes it. PS. No doubleposting, mate.
-
I don't understand why are you using his code, because I just tested mine and it worked. His script doesn't even use tables which are CRITICAL for this kind of chatbox script.. And I think you should look around the nametag function, what do you think is wrong or do you want us to do everything now? It's basically the most basic thing that there is no player mentioned on that function, that's kind of... basic stuff... there should be some kind of player mentioned, you find out what.
-
meta.xml <meta> <info name="Chatbox" type="script" /> <script src="server.lua" type="server" /> <!-- Server --> </meta> acl.xml <group name="Admin"> <acl name="Moderator"></acl> <acl name="SuperModerator"></acl> <acl name="Admin"></acl> <acl name="RPC"></acl> <object name="user.[color=#00FF00][b]youraccounthere[/b][/color]"></object> </group> server.lua (untested) local root = getRootElement() function chatbox(...) local account = getAccountName(getPlayerAccount(source)) local name = getPlayerName(source) local word = { ... } local text = table.concat(word, " ") if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000[ADMIN] " .. name .. ": " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [ADMIN] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FFAE00[sMOD] " .. name ..": " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [sMOD] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#00FF00[MOD] " .. name .. ": " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [MOD] " .. name .. ": " .. text) end end addEventHandler("onPlayerChat", root, chatbox)
-
Ah, right, thanks a lot!
-
Well, a lot of things that had to be changed, but try this. Not tested! function chatbox(player, ...) local ncolor = getPlayerNametagColor() local name = getPlayerName(player) local word = { ... } local text = table.concat(word, " ") local account = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000[ADMIN] " .. ncolor .. name .. ": " .. text, getRootElement(), 255, 255, 255, true) outputServerLog("CHAT: [ADMIN] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FFAE00[sMOD] " .. ncolor .. name ..": " .. text, getRootElement(), 255, 255, 255, true) outputServerLog("CHAT: [sMOD] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#00FF00[MOD] " .. ncolor .. name .. ": " .. text, getRootElement(), 255, 255, 255, true) outputServerLog("CHAT: [MOD] " .. name .. ": " .. text) end end addEventHandler("onPlayerChat", getRootElement(), chatbox)