![](https://forum.multitheftauto.com/uploads/set_resources_22/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Dealman
Members-
Posts
1,421 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Dealman
-
No need to keep double-posting all the time, people will help you when they have time. The reason it's not working is obvious, the event is already handled. This is the entire function; As you can see, the function already exists - this is triggered whenever someone tries to spawn a vehicle via the F1 menu. So all you need to do is edit this code which I gave you. else -- If the player does NOT have permission, output a message outputChatBox("You're not allowed to spawn this vehicle!", source, 187, 0, 0, true) end This message will be shown for players that do not have the permission, so you already have the general behaviour needed. All you need to do is to make it so it takes away their money. Another thing you did wrong is the variable Hunter. You can't just expect MTA to magically know what that variable should contain - you need to actually define it first. But since we already know the ID of the Hunter(520) we don't need to define a variable. All in all, it would look like this; else if(getPlayerMoney(source) >= 25000) then takePlayerMoney(source, 25000) vehicle = createVehicle(520, vx, vy, vz, 0, 0, vrot) else outputChatBox("You can't afford this vehicle! ($25 000)", source, 187, 0, 0, true) end end As you can see it's a really easy solution, and you'd probably have been able to figure it out if you read what I wrote thoroughly as well as follow examples on the MTA Wiki. If you don't know how to structure if statements properly, then you can search on google for information instead of rushing back here to bump your thread. If you can't take the time to try and help yourself, don't expect us to help you. You can't always expect to get everything served on a silver platter.
-
Of course it's possible, but try and do it yourself this time. I already showed you where the relevant code is. getPlayerMoney -- Check if the player has $25 000 takePlayerMoney -- If the player can afford it, take away $25 000 of their money Edit: A little hint, you only need to modify this piece of code; else outputChatBox("You're not allowed to spawn this vehicle!", source, 187, 0, 0, true) end
-
allAmbiMarkers is defined at the top of your script, yet in the for loop you're trying to define it as a local variable. Try and change it to; allAmbiMarkers[i] = createMarker(v[1], v[2], v[3], ambiType,ambiSize, aR ,aG, aB)
-
Go to resources/[gameplay]/freeroam and open up the file fr_server.lua. Find this line; vehicle = createVehicle(vehID, vx, vy, vz, 0, 0, vrot) Try changing it to this; if(vehID == 520) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then vehicle = createVehicle(vehID, vx, vy, vz, 0, 0, vrot) else outputChatBox("You're not allowed to spawn this vehicle!", source, 187, 0, 0, true) end else vehicle = createVehicle(vehID, vx, vy, vz, 0, 0, vrot) end
-
I'm well aware of this. But the title of the thread is "Ho i can make elseif in script ?", and since he didn't seem to know how to properly structure the if statements - I thought I'd help him out. I never said your method does not work.
-
If you for some reason don't wanna use the or operator, this is how you properly make use of if statements in Lua; function shout(player, cmd, ...) local accountname = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("Admin")) then -- If true, code here -- If false, check next if statement elseif isObjectInACLGroup("user." .. accountname, aclGetGroup("Console")) then -- If true, code here -- If false, check next if statement elseif isObjectInACLGroup("user." .. accountname, aclGetGroup("SuperModerator")) then -- If true, code here else -- If all above if statements fail, you can use else outputChatBox("You do not have permission to use this command!", player, 187, 0, 0) end end Things to note; • if and elseif both need to end with then otherwise it will return an error. • else does not require then as it is used if the previous if statements failed.
-
Personally I prefer not to use OOP when scripting Lua, so I won't comment on these questions. As for Question 2, you basically answered it yourself already. As far as I know there wouldn't be too big differences whether you have many small or just a big one. If you have lots of smaller ones, refreshing all the resources could take some time - and it might end up a bit unorganized in terms of folder structure. If you make a big one, there would be less resources to refresh - but the loading time of this resource might be considerably longer(but this shouldn't matter if it's only started along with the server). The biggest drawback as I see it, is the one you just said yourself - not being able to apply fixes and updates without having to restart the entire thing. I think in the end, it mostly comes down to personal preference above anything else. There may be some differences in terms of performance, but I doubt they'd be too severe to become gamebreaking.
-
Could always add yourself just for testing purposes. Trying a resource might work as well
-
Maybe it doesn't show up because it doesn't have any object(s) assigned yet?
-
Rather than relying on people to try and explain it to you, sit down, and try it out. Trial and error is arguably the best way you'll learn scripting and/or programming - you just need the patience and don't give up just because your first few attempts didn't succeed. The wiki already explains to you what a render target actually is, but I guess it could use some clarification; Think of it like a canvas, or a layer like in photoshop. You can draw things inside this canvas using your usual drawing functions such as dxDrawText, dxDrawRectangle, dxDrawImage and so on. And since the render target returns a texture, you can also apply stuff like shader effects onto this render target. dxSetRenderTarget is a bit more difficult to try and explain in such a way it would make sense. But essentially, you'll want to use this before you start drawing stuff onto the render target, by supplying this function with your render target - you're telling MTA to draw onto that render target. Otherwise, it will just be drawn onto the screen like usual(since the render target is actually an invisible texture, this might be a bit confusing). So when you don't provide any arguments, you're telling MTA to draw onto the screen, instead of your previously set render target. They can be used for a variety of things, including things such as DX editboxes, DX gridlists, DX scrollbars and etc etc. Not necessarily the most efficient way of doing this, but since it's a DX element - you can manipulate it pretty much however you'd like. I won't give you any examples just yet, go ahead and try it for yourself. Start simple and go from there. For example, start with drawing an image onto the render target - and try and make it so half of the image is cut off(because it's outside the render target) using dxSetRenderTarget and the clear argument.
-
Well, you can remove the function moveOnStart since it won't really be doing anything. It will always give you that error when the server is started, it may work whenever a resource is started though - so long as there are players. If you want to prevent the error from showing up, simply add an if statement. if(player) then check(player) end
-
It's giving you an error because you're using onResourceStart. As soon as the server is started, it will run your code - and since no players are on the server yet - getElementsByType will return false. Also, since you're using root for that event, it will be triggered every time any server-side resources is started/restarted.
-
Yeah, you could use dxCreateRenderTarget. When you update the render target with dxSetRenderTarget you have the optional argument called clear. Set this to true, and anything outside of the render target will not be visible.
-
Doesn't the definition go into the meta file instead of the map?
-
Each, if you ever would want to sell something, I sincerely suggest that you work on your attitude a bit. Olle's reply was not disrespectful - it seemed honest. And that's more than what you have offered in this thread. Why do we have to PM you in order to see screenshots of your scripts? You clearly have the screenshots already, so why not just post them here? It would not only save our time, but also yours. Also, joking about the price for which you would sell the stuff isn't the slightest funny. I personally wouldn't buy anything from someone with such an immature attitude.
-
The YouTube BB codes do work, enter only the video ID.
-
Not entirely sure what you're asking for... I'm assuming what you're looking for is getPlayerFromName?
-
What do you mean he can't do that? Of course you can read the meta.xml file using the XML functions. Also, programming/scripting is all about logical thinking - so why say "Don't even think. Learn scripting!"...? @Matevsz: 1. The variable player is not defined 2. You overwrite the table "samochody" with the XML handle. 3. Are you sure you have an ACL group called "player"?
-
Aye; setElementStreamable
-
You should also be able to use URL tags. For example; "https://www.youtube.com/embed/DLzxrzFCyOs?autoplay=1" There are more tags you can pass through the URL as well. See this link for more information.
-
Yeah, I understood that, I simply said that you still have functions which belong to the MySQL Module in your code. Those will return nil errors because the function doesn't exist. I also need to know what code is on Line 22.
-
Well, if you don't have the module installed, these functions do not exist; mysql_escape_string mysql_num_rows mysql_free_result What code is on Line 22? This? function onLogin ( player, user, pass )
-
Seems like this uses the MySQL module, do you have this installed?
-
Yeah, you can. Use getElementsByType to get all the vehicles, then loop through them and use setVehicleHandling.