Jump to content

how to make a gamemode?


Guest blbl

Recommended Posts

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

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

Nice to hear you want to MAKE one. :P

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. xD

Link to comment
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
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
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

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
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
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
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
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. :P

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...