- 
                Posts1,461
- 
                Joined
- 
                Last visited
- 
                Days Won34
Everything posted by DiSaMe
- 
	Lua and Squirrel are quite similar. Like Squirrel, Lua is dynamically typed, and even local variables are defined in the same way (keyword 'local'). Also, I'm not sure, but tables look exactly the same to me. Block syntax is different (Squirrel uses C-like syntax, so it has { and }, while Lua uses words, such as 'then' and 'end'). In addition, Lua doesn't have classes, though you can use metatables to make tables work like classes. So if you know Squirrel, Lua should be easy to learn. As for Pawn, it's harder than Lua since you have to care about data types and some other low-level stuff.
- 
	You can save the files using file functions and load the scripts using loadstring fileCreate fileOpen fileWrite fileRead loadstring
- 
	Send the map data to players and create the objects on the client side triggerClientEvent --or triggerLatentClientEvent
- 
	data/maps/oceandrv/oceandrv.ide has objects with these model IDs defined: 3096, od_walkway2, od_lighthouse, 1, 200, 0 3097, od_walkway3, od_lighthouse, 1, 125, 0 3100, od_lightext, od_lighthouse, 1, 150, 132 3248, od_lightint, od_lighthousein, 1, 66, 128 The second column is the name of DFF and COL. DFF should be in models/gta3.img and COL is probably a part of data/maps/oceandrv/oceandrv.col archive. Took 5 minutes to find
- 
	The scale is changed for every client aware of the object being scaled. If it's scaled on the server, then it's scaled for all clients, and that's how most functions available on both server and client work. What you wrote makes it feel like the function doesn't work for anyone except D&G
- 
	If server and client scripts were completely separate, the latter ones would be nearly useless. But since client-side scripts can use all elements the client sees and server-side elements are visible for client, you can use functions on server-side elements in client-side scripts. The general ways to transfer the data between server and client are custom events and element data: addEvent addEventHandler triggerServerEvent triggerClientEvent setElementData getElementData When you cross-trigger the event on one side, the handler functions for that event on the other side will be called. You can pass the data as additional arguments and it will be transfered to another side. Element data is a simpler way to synchronize data: whatever you set on server/client becomes automatically synced for server and all clients unless you set the synchronize argument to false. Also, you can set the synced identifier and use it to get the element on the client: setElementID getElementByID
- 
	It shouldn't be hard to remake the gravity yourself. getElementVelocity setElementVelocity
- 
	Since static objects don't collide with each other, that requires a script which detects the collisions and applies the force itself. You can do this using these functions: isLineOfSightClear processLineOfSight setElementVelocity setVehicleTurnVelocity But that requires some experience related to calculations in 3D.
- 
	Is collision really disabled? When you walk into the object, do you go through it? If so, then yes, the collision is disabled. But if the object only goes through other objects, that's not a 'bug'. It's just the way the attachments work. First, the attached element is fixed to the attachment offset. And second, the physics of attached element do not affect the element it's attached to. As a result, it acts line an object of infinite mass. When it intersects other objects of infinite mass, they go through each other. But if it collides an element of a finite mass (such as a vehicle), that element gets pushed with no effort.
- 
	Unless I have missed something, there's nothing in the script what could prevent it from working. Maybe you didn't set it to client-sided in meta.xml? And if you want to prevent some weapons from inflicting damage, there's no need to make a long condition check. Better use tables for that. Instead of doing this: if value == 5 or value == 9 or value == 11 then You can make a table of values (usually at the top of the script): validValues = { [5] = true, [9] = true, [11] = true } And check the condition in this way: if validValues[value] then
- 
	k is the key in your loop. That means, it has values 'w1', 'w2' and 'w3' during iterations.The problem is that you try converting these values to numbers. That fails and tonumber function returns nil.
- 
	setPedAnimation: Just set that argument to false...
- 
	getElementData returns whatever was set, not necessarily a string. If it returns a boolean, it means either a boolean was set or there was no value set at all.
- 
	As addCommandHandler page in wiki says, handler function has player and command name as the first parameters: player playerSource, string commandName, [string arg1, string arg2, ...] So the first line should look like this: function pay(player, command, amount) In addition, since player may enter the command without writing the amount, you should check if tonumber(amount) returns a number value. Otherwise warning messages will show up.
- 
	In setTimer, the first argument is the function you want to be called, then goes the time and execution count and further is whatever you want to pass to the called function. So if you want destroyElement(smoke) to be delayed, you have to call setTimer like this: setTimer(destroyElement, 2500, 1, smoke)
- 
	Thanks for the answer, I think it was helpful. Although I don't feel interested in this now, I may try doing something later.
- 
	Nu taip, nelabai daug čia mūsų Gal pavyktų daugiau žmonių į MTA pritraukti, jei normalų ped'ų valdymo script'ą padaryčiau. NPC HLC toks nenusisekęs išėjo, tai dabar geresnį po truputį darau.
- 
	O jei tiksliau? Kokių pagrindų? MTA, Lua ar apskritai programavimo?
- 
	First, event "onPlayerChat" only has 2 arguments, the message and its type. Second, your function theFormat does nothing. And third, using "id" as the name of the function is confusing, especially when there's a variable with the same name. This could lead to the situations in which you try to use a value without noticing that it's being overriden by another value.
- 
	I have a question about Doppler effect. Should the objects appear red when you slowly move towards them? I thought they should be red when you move away from them. When you approach them, the wavelength decreases (blue shift), and when you move away, it increases (red shift).
- 
	There is no problem with usage of require function in the library, because removing it and including the files into meta.xml will have the same effect (unless I have missed something). Since the library is grid-based and for 2D games, its usage in MTA would limit the pathfinding to 2D plane. As for single player AI, it's not worth bringing it to MTA. It would require some effort to make it synced, and it relies on client-side data too much. Remaking it in scripts is better. Actually, NPC HLC was my attempt to do something like that, but since I was focused on the traffic script, the basic tasks were priority and NPC HLC didn't come out really good. I won't update it, but I may make another ped-controlling script from scratch. The problem which often makes scripting harder is making the script control all peds at the same time. But I recently realized that Lua coroutines are a good way to avoid this because they allow scripting of a single ped in continuous code without having to care about other peds.
- 
	If you don't use the result of the query, it's better to use this function: dbExec
- 
	Do you use dbFree or dbPoll to release the query result from memory?
- 
	If you want the weapon to be visible on every client, you have to create it on every client, simple.

 
        