Jump to content

Problems with my Gamemode


Giovanni

Recommended Posts

Hello,

I wanted to give MTA a try and created my first little gamemode. Since I came from SA:MP [is it allowed to mention it here?] I am kind of lost. I did get the script working but some things totally confuse me.

_____________________________________________________________

Informations:

meta.xml

<meta> 
    <info author="Giovanni" description="Deathmatch" /> 
    <script src="ldm.lua" /> 
    <script src="client.lua" type="client" /> 
    <map src="broph.map" /> 
</meta> 

_____________________________________________________________

1. Combining Client and Server sided scripts?

I know that some functions only work when they are server / client sided. But can I somehow combine them, or call a client sided function from a server sided script for example?

I got this:

client.lua

addEventHandler("onPlayerJoin", root, 
    function() 
        outputChatBox("#FF4444Welcome to my awesome Server!"); 
    end 
) 

I know that "onPlayerJoin" doesn't work if it is client sided, but how could I do this then? Would "onClientResourceStart" come close to what I want in this case?

2. Adding player classes?

I was searching for a function like "AddPlayerClass" or something like that, but obviously, I wasn't successful, otherwise I would not post here. What are the class functions? Like AddPlayerClass, SetPlayerTeam or so?

Thanks in advance!

Link to comment

onClientPlayerJoin will be executed for everyone but the player who just joined.

Why don't you use it server side instead?

There's no "player classes", maybe you mean teams? if so, search for the team functions in the mta wiki (wiki.multitheftauto.com).

Link to comment
onClientPlayerJoin will be executed for everyone but the player who just joined.

Why don't you use it server side instead?

There's no "player classes", maybe you mean teams? if so, search for the team functions in the mta wiki (wiki.multitheftauto.com).

Ok I found the team functions. Thanks for that. But well, I want to display a gui when a player connects, so that they can choose their class. And if I'm not wrong than a gui can only be used client sided.

Link to comment
That's right, GUI is only client side.

And for that is simple, use onClientResourceStart (when the client finishes downloading the required files).

Ok thanks again for the moment. But a stupid question;

Since the GUI is client sided [i guess the function that is called if a player selects a gui element is also client sided (?)] and "setPlayerTeam" is server sided, this won't really work or?

Link to comment

Well, that's why there are two functions to send data to the client or server.

check out triggerServerEvent (so you can send something, or make an event in the server to change his team)

a lil example:

-- server side

addEvent("setMyTeam",true) 
addEventHandler("setMyTeam",root, 
function (thePlayer) 
     setPlayerTeam(thePlayer, theTeamElement) 
end) 

-- client side

triggerServerEvent("setMyTeam",getLocalPlayer(),getLocalPlayer()) 

I hope you understand.

Link to comment
Well, that's why there are two functions to send data to the client or server.

check out triggerServerEvent (so you can send something, or make an event in the server to change his team)

a lil example:

-- server side

addEvent("setMyTeam",true) 
addEventHandler("setMyTeam",root, 
function (thePlayer) 
     setPlayerTeam(thePlayer, theTeamElement) 
end) 

-- client side

triggerServerEvent("setMyTeam",getLocalPlayer(),getLocalPlayer()) 

I hope you understand.

Ah I see. I came across this function already but now I also know what it exactly does (it's pretty obvious though). Thanks for the help!

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