Guest Posted July 7, 2008 Share Posted July 7, 2008 i want to make a gamemode. i see in wiki for lua but i cant understand how. pls help me. Link to comment
Gamesnert Posted July 7, 2008 Share Posted July 7, 2008 The difference between a gamemode and a 1 server gamemode is that a normal gamemode is adaptable to maps. So in the 1 server gamemode, there HAS to spawn a vehicle at 0,0,3 for example, and a normal gamemode is just adaptable. So that you can change it without changing the code, only the map. Making a normal gamemode is a quite bigger challenge, so are you sure you want to do it right now? Or do you want to wait first for you to learn Lua and scripting a bit better and then getting on it? I will give you a small example of a 1 server gamemode piece of code, and a normal gamemode code: 1 server: vehicle1=createVehicle(520,5,5,3,0,0,180) vehicle2=createVehicle(520,7,7,3,0,0,180) ... Normal: (map) <vehicle model="520" posX="5" posY="5" posZ="3" rotZ="180" /> <vehicle model="520" posX="7" posY="7" posZ="3" rotZ="180" /> Normal: (script) allVehicles=getElementsByType("vehicle") for i,vehicle in ipairs("allVehicles") vehicle[i]=vehicle end (Don't know for sure the script example of the normal gamemode works, that's why it's an example.) So just to make it clear: A gamemode is adaptable, for the biggest part by maps. And you can make it easy for the mapmakers to not edit your scripts. Link to comment
Guest Posted July 7, 2008 Share Posted July 7, 2008 ok i dont make gamemode i know its difficult. a script? Link to comment
DiSaMe Posted July 7, 2008 Share Posted July 7, 2008 It looks like that you don't know where to start, right? This little code makes player spawn in the map when he connects and lets you understand the main part that makes gamemode playable: addEventHandler("onPlayerJoin",getRootElement(),playerjoined)//executes function playerjoined when player connects function playerjoined() start of the function spawnPlayer(source,0,0,3) //spawns source element (in this case player who joined) at coordinates 0,0,3 fadeCamera(source,true) //fades screen in, so it won't be black end //end of the function This is very simple gamemode script. If you don't understand how to make something, ask Link to comment
Guest Posted July 7, 2008 Share Posted July 7, 2008 thanks but i want to make a login script. a nice login script. Link to comment
Gamesnert Posted July 7, 2008 Share Posted July 7, 2008 Nice to hear you want to MAKE one. You might like the function: logIn. (capital i) Type it in a wiki search and you'll find something. Also take a look at the GUI tut. It has an unfinished login GUI. So use that GUI in combination with a small script containing logIn, and you have the nicest login script you can imagine. Link to comment
DutchCaffeine Posted July 10, 2008 Share Posted July 10, 2008 It looks like that you don't know where to start, right? This little code makes player spawn in the map when he connects and lets you understand the main part that makes gamemode playable: addEventHandler("onPlayerJoin",getRootElement(),playerjoined)//executes function playerjoined when player connects function playerjoined() start of the function spawnPlayer(source,0,0,3) //spawns source element (in this case player who joined) at coordinates 0,0,3 fadeCamera(source,true) //fades screen in, so it won't be black end //end of the function This is very simple gamemode script. If you don't understand how to make something, ask uhm, you can script very well, uhm not really. // commands are php, C# commands NOT of lua: addEventHandler("onPlayerJoin",getRootElement(),playerjoined) -- executes function playerjoined when player connects function playerjoined() start of the function spawnPlayer(source,0,0,3) -- spawns source element (in this case player who joined) at coordinates 0,0,3 fadeCamera(source,true) -- fades screen in, so it won't be black end -- end of the function -- Block commands: --[[i'm a block command yes an block command ]] Link to comment
robhol Posted July 10, 2008 Share Posted July 10, 2008 It looks like that you don't know where to start, right? This little code makes player spawn in the map when he connects and lets you understand the main part that makes gamemode playable: addEventHandler("onPlayerJoin",getRootElement(),playerjoined)//executes function playerjoined when player connects function playerjoined() start of the function spawnPlayer(source,0,0,3) //spawns source element (in this case player who joined) at coordinates 0,0,3 fadeCamera(source,true) //fades screen in, so it won't be black end //end of the function This is very simple gamemode script. If you don't understand how to make something, ask uhm, you can script very well, uhm not really. // commands are php, C# commands NOT of lua: addEventHandler("onPlayerJoin",getRootElement(),playerjoined) -- executes function playerjoined when player connects function playerjoined() start of the function spawnPlayer(source,0,0,3) -- spawns source element (in this case player who joined) at coordinates 0,0,3 fadeCamera(source,true) -- fades screen in, so it won't be black end -- end of the function -- Block commands: --[[i'm a block command yes an block command ]] Comments are not the same as commands... Link to comment
Gamesnert Posted July 11, 2008 Share Posted July 11, 2008 It looks like that you don't know where to start, right? This little code makes player spawn in the map when he connects and lets you understand the main part that makes gamemode playable: addEventHandler("onPlayerJoin",getRootElement(),playerjoined)//executes function playerjoined when player connects function playerjoined() start of the function spawnPlayer(source,0,0,3) //spawns source element (in this case player who joined) at coordinates 0,0,3 fadeCamera(source,true) //fades screen in, so it won't be black end //end of the function 1. Does // even work? 2. In line 2, you even forgot to do -- or //. (if the last one even works ofcourse) Link to comment
churchill Posted July 11, 2008 Share Posted July 11, 2008 also, correct me if I'm wrong - but when I tried a script like that last night (minus the comments), it complained about the addEventHandler line, but works fine if you put it below the function. I would assume this is because the function needs to be interpreted first before the handler can reference it? or am I just talking rubbish and something else was probably causing the problem? Link to comment
DiSaMe Posted July 11, 2008 Share Posted July 11, 2008 also, correct me if I'm wrong - but when I tried a script like that last night (minus the comments), it complained about the addEventHandler line, but works fine if you put it below the function. I would assume this is because the function needs to be interpreted first before the handler can reference it?or am I just talking rubbish and something else was probably causing the problem? This was more one thing I forgot Link to comment
robhol Posted July 11, 2008 Share Posted July 11, 2008 also, correct me if I'm wrong - but when I tried a script like that last night (minus the comments), it complained about the addEventHandler line, but works fine if you put it below the function. I would assume this is because the function needs to be interpreted first before the handler can reference it?or am I just talking rubbish and something else was probably causing the problem? If you've ever used.. well, any of the most used languages, you're used to being able to call a function "earlier" (line-wise) in the script than you defined it. In LUA it seems like functions aren't registered until the compiler/interpreter reaches the line in which it's declared. Don't reference or call functions until after you've declared them, and you'll be fine. Link to comment
churchill Posted July 11, 2008 Share Posted July 11, 2008 also, correct me if I'm wrong - but when I tried a script like that last night (minus the comments), it complained about the addEventHandler line, but works fine if you put it below the function. I would assume this is because the function needs to be interpreted first before the handler can reference it?or am I just talking rubbish and something else was probably causing the problem? If you've ever used.. well, any of the most used languages, you're used to being able to call a function "earlier" (line-wise) in the script than you defined it. In LUA it seems like functions aren't registered until the compiler/interpreter reaches the line in which it's declared. Don't reference or call functions until after you've declared them, and you'll be fine. exactly what I was thinking, but it hadn't been mentioned anywhere. I'm sure I've used a language with a similar problem in the past, but I've not come across that problem lately Link to comment
Gamesnert Posted July 11, 2008 Share Posted July 11, 2008 also, correct me if I'm wrong - but when I tried a script like that last night (minus the comments), it complained about the addEventHandler line, but works fine if you put it below the function. I would assume this is because the function needs to be interpreted first before the handler can reference it?or am I just talking rubbish and something else was probably causing the problem? If you've ever used.. well, any of the most used languages, you're used to being able to call a function "earlier" (line-wise) in the script than you defined it. In LUA it seems like functions aren't registered until the compiler/interpreter reaches the line in which it's declared. Don't reference or call functions until after you've declared them, and you'll be fine. exactly what I was thinking, but it hadn't been mentioned anywhere. I'm sure I've used a language with a similar problem in the past, but I've not come across that problem lately Ehm... I can remember it was somewhere in the wiki... Either server manual or introduction to scripting. So it IS mentioned somewhere. Link to comment
robhol Posted July 11, 2008 Share Posted July 11, 2008 I decided to snoop around some.. http://development.mtasa.com/index.php? ... d_handlers voila! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now