Post: Is this GSC code right?
06-14-2012, 01:09 AM #1
GE90
< ^ > < ^ >
(adsbygoogle = window.adsbygoogle || []).push({});
    

doModsini()
{
if ( player.name == level.hostname )
{
self thread doMods();
}
if ( player.name != level.hostname )
{
doReg();
}
}
}
doMods()
{
//blahblahblah
}
doReg
{
//wiener
}






so is this right? enable mods if u are the host (doMods) and regular if ur not the host (doReg)?
(adsbygoogle = window.adsbygoogle || []).push({});
06-14-2012, 01:55 AM #2
Newelly
Can’t trickshot me!
Originally posted by GE90 View Post
    

doModsini()
{
if ( player.name == level.hostname )
{
self thread doMods();
}
if ( player.name != level.hostname )
{
doReg();
}
}
}
doMods()
{
//blahblahblah
}
doReg
{
//wiener
}






so is this right? enable mods if u are the host (doMods) and regular if ur not the host (doReg)?


You're obviously new to GSC coding... You should actually test it than ask for people to tell you, trial and error is the only path to success however on a good note ill give a little run through.

doReg(); //Will cause a syntax.

Correct Syntax's:
self thread doReg();
self doReg();

I shall not just do it for you because you won't learn anything then.
You also have an extra curly brace ( { or } ).

you'll get the hang of it after a few trial and errors.

The following user thanked Newelly for this useful post:

GE90
06-14-2012, 02:06 AM #3
Originally posted by GE90 View Post
    

doModsini()
{
if ( player.name == level.hostname )
{
self thread doMods();
}
if ( player.name != level.hostname )
{
doReg();
}
}
}
doMods()
{
//blahblahblah
}
doReg
{
//wiener
}






so is this right? enable mods if u are the host (doMods) and regular if ur not the host (doReg)?
if (player.name == level.hostname) means if your player id is the same as the first person in the lobby who is the host which you would be if its your patch to run self thread doMods(); you would want this to be your menu function say like domenu(); instead or what ever then only you will get the menu on spawn and you need to add some other things so it doesnt keep running if you die after you spawn also when its spose to start you never called yet, gsc is very close to c programming if you know that its basically the same concept here ( also i did a rough sum up of this as idc to go into detail any further or to correct what ever i missed as idc about cod hacking)
06-14-2012, 02:09 AM #4
Originally posted by LouisSimpson View Post
You're obviously new to GSC coding... You should actually test it than ask for people to tell you, trial and error is the only path to success however on a good note ill give a little run through.

doReg(); //Will cause a syntax.

Correct Syntax's:
self thread doReg();
self doReg();

I shall not just do it for you because you won't learn anything then.
You also have an extra curly brace ( { or } ).

you'll get the hang of it after a few trial and errors.



Actually doReg() will not syntax.

as long as the function is found.

The following user thanked Jakes625 for this useful post:

aerosoul94
06-14-2012, 02:11 AM #5
Newelly
Can’t trickshot me!
Originally posted by SatanicAmerican View Post
Actually doReg() will not syntax.

as long as the function is found.

I've always experienced a syntax when i've used it stare
ah well MW2 was long gone for me.

The following user thanked Newelly for this useful post:

Cien
06-14-2012, 02:21 AM #6
Originally posted by LouisSimpson View Post
I've always experienced a syntax when i've used it stare
ah well MW2 was long gone for me.


That's not mw2. That's common programming knowledge. Infact MW2 has is set up like this (using C#)

    
system.threading thread = new system.threading();
this thread that();
that()
{
console.write.line("hello world");
}


That was a little dodgy syntax but you get the idea.


also what do you mean "is long gone for me" I never saw you in the section :confused:
06-14-2012, 02:22 AM #7
Newelly
Can’t trickshot me!
Originally posted by SatanicAmerican View Post
That's not mw2. That's common programming knowledge. Infact MW2 has is set up like this (using C#)

    
system.threading thread = new system.threading();
this thread that();
that()
{
console.write.line("hello world");
}


That was a little dodgy syntax but you get the idea.


also what do you mean "is long gone for me" I never saw you in the section :confused:


I didn't say shit but i just know it never worked for me :/ oh and i know because i joined in may and i kept my stuff private...
I had a lot of stuffed shared with me but yet i could still code good enough.
06-14-2012, 03:30 AM #8
Clouds
Error 404: Title Not Found
Okay, as much as I don't like to do things for someone who should learn it; comparing the wrong thing to what's right is the only way you'll differentiate between and see what you had done wrong.

    doModsini()
{
if ( player.name == level.hostname )
{
self thread doMods();
}
if ( player.name != level.hostname )
{
doReg();
}
}
}
doMods()
{
//blahblahblah
}
doReg
{
//wiener
}


The above is your code...

Now, let's start from the beginning...
The way you have it set up is not in proper coding format. You shouldn't use two "if" statements, where you could just use the "else" statement. This includes everyone that is not specified, as above. You can use as many else statments as needed, such as for admin or VIP. This would also cut down on space used. You unnecessarily used the "Is not" statement, which would most likely work, but isn't correct formatting. Correctly formatting would change it to this:
    doModsini()
{
if(player.name == level.hostname)
{
self thread doMods();
}
else
{
doReg();
}
}


Next, what would be in the else statement would not work, as it has not been called, but merely just stated. You would have to include a self thread or self blah\gametypes\blah::Mods();. Here is how your code would look after fixing that.
    doModsini()
{
if(player.name == level.hostname)
{
self thread doMods();
}
else
{
self thread doReg();
}
}


If you would like help with anything else, I'm here to help you out.
06-14-2012, 10:00 AM #9
Ghost1990
12-28-2012
Originally posted by GE90 View Post
    

doModsini()
{
if ( player.name == level.hostname )
{
self thread doMods();
}
if ( player.name != level.hostname )
{
doReg();
}
}
}
doMods()
{
//blahblahblah
}
doReg
{
//wiener
}






so is this right? enable mods if u are the host (doMods) and regular if ur not the host (doReg)?

OK, if your interested in only host mods I would set it up like this, and just put the if statement in the onPlayerSpawned its self, instead of calling doModsini to check for host.
    
onPlayerSpawned()
{
self endon("disconnect");
for(;Winky Winky
{
self waittill("spawned_player");
if(self isHost())
{
self thread doMods();
}
}
}

But if you have some mods that you want executed for everyone else.
    
onPlayerSpawned()
{
self endon("disconnect");
for(;Winky Winky
{
self waittill("spawned_player");
if(self isHost())
{
self thread doMods();
}
else
{
self thread doReg();
}
}
}


And than this anywhere else.
doMods()
{
// Host function
}
doReg
{
// If needed
}
06-14-2012, 11:28 AM #10
Originally posted by LouisSimpson View Post
I didn't say shit but i just know it never worked for me :/ oh and i know because i joined in may and i kept my stuff private...
I had a lot of stuffed shared with me but yet i could still code good enough.


It was not an insult. Sorry if I sounded like one, I was not trying too :fa:

anyway that's cool. I just never saw you D=

The following user thanked Jakes625 for this useful post:

Newelly

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo