Page 4 of 5

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 12:23 am
by Rezil
I'm pretty sure setText() takes a localized string as a parameter, try putting a & in front, something along the lines of

Code: Select all

xuidText setText(&""+nameshow);
Also, does self.getxuid actually hold a value?

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 12:35 am
by F |Madness| U
Rezil wrote:I'm pretty sure setText() takes a localized string as a parameter, try putting a & in front, something along the lines of

Code: Select all

xuidText setText(&""+nameshow);
Also, does self.getxuid actually hold a value?
I tryed that and got error "pair `` and `undefined` are not `localised string` and `undefined`" or something.

And I'm not sure if self.getxuid holds a value, I'm a noob scripter, but getxuid is a valid function, so would self.getxuid get the players xuid? (xuid is similar to a guid afaik but without pb).

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 12:51 am
by Rezil

Code: Select all

xuid = self getXUID();
xuidTest setText(&xuid);
I hope you can localize variables, otherwise you're going to have to make a localized string file or set your HUD text some other way.

Another question, does your code otherwise work? I mean the text on screen part, self.getxuid doesn't do anything since it's not a valid entity variable.

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 10:35 am
by F |Madness| U
Yeah the rest of the code on screen works, I've been searching and trying many other things (a post on another forum said that):

Code: Select all

self iprintlnbold(self.guid);
in OnPlayersConnect() would work, but it comes up with "struct is not an entity" error. Really stuck on this at the moment!

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 10:51 am
by Drofder2004
F |Madness| U wrote:Yeah the rest of the code on screen works, I've been searching and trying many other things (a post on another forum said that):

Code: Select all

self iprintlnbold(self.guid);
in OnPlayersConnect() would work, but it comes up with "struct is not an entity" error. Really stuck on this at the moment!
self.guid is (at least in CoD4) not a valid value.

If you do "self.guid = self getGUID();" then you will be able to do "iprintlnbold(self.guid);"

Or simply "iprintlnbold(self getGuid());"

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 11:29 am
by IzNoGoD
F |Madness| U wrote:Yeah the rest of the code on screen works, I've been searching and trying many other things (a post on another forum said that):

Code: Select all

self iprintlnbold(self.guid);
in OnPlayersConnect() would work, but it comes up with "struct is not an entity" error. Really stuck on this at the moment!

Struct is not an entity implies that self is not defined there - please correct me if im wrong, as im not familiar with any code other than cod2's, and this thread doesnt exist there.

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 12:40 pm
by F |Madness| U
Argh this is weird. I tested iprintlnbold(getDvar("g_gametype")); and it worked, printed the gametype on the screen.
I then tested a variety of different ways, including iprintlnbold(getMapName());, iprintlnbold(getClientName());, iprintlnbold(getWeaponName());. (All of these are listed as functions on Black Ops), and for all of those I received unknown function error.

And if I tryed iprintlnbold(self getxuid());, I didn't get unknown function, but struct is not an entity error. Would anyone be able to try and explain some of this to me? :S

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 12:47 pm
by IzNoGoD
IzNoGoD wrote:

Struct is not an entity implies that self is not defined there - please correct me if im wrong, as im not familiar with any code other than cod2's, and this thread doesnt exist there.
Define self
Also, stop calling stuff on nothing, like getclientid();. Use self getclientid() instead, AFTER you defined self


http://modsonline.com/Forums-top-134675.html <--tutorial you should read

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 1:55 pm
by F |Madness| U
Thankyou very much for that tutorial, I understand self/player/level much more than I did before now!

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 7:57 pm
by F |Madness| U
If somebody could explain this code to me it would be great, basically when you press melee button music plays, and when you press it again it stops. Code is

Code: Select all

for(;;)
{
while(!self MeleeButtonPressed())
wait 0.05;
clientnotify("notify_stones");
iPrintLnBold("^1Music On");
wait 0.2;
while(!self MeleeButtonPressed())
wait 0.05;
clientnotify("none");
iPrintLnBold("^1Music Off");
wait 0.2;
}
Now doesn't this mean the argument is (not pressing melee button), so when the argument is true, it infinitely loops. Therefore shouldn't the music be constantly stopping/starting when you're not pressing melee? I've definitely got the wrong concept or something, if somebody could explain it in `simpleton` terms it would be awesome.

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 8:09 pm
by Rezil
It's sloppy coding, and it's putting a considerable ammount of stress on the server. Basically it's an infinite loop, inside it checks if the melee button is not pressed(so if self MeleeButtonPressed() returns false). If it is false, it constantly waits for 0.05 seconds until you press the melee button, then it notifies the player and prints text on the screen. After that it loops again for the same thing, just notifying something else.

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 8:18 pm
by F |Madness| U
Okay thanks Rezil, I think I understand it now. Just wondering you said it would put a considerable amount of stress on the server, so if there was lots of code that did this, would it basically make the server lag alot? And how might that code be edited to put less stress on, because as a beginner I don't really know what will put stress onto a server or not. (This wasn't my code by the way). -Thanks.

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 8:23 pm
by Drofder2004

Code: Select all

for(;;)
{
   /* While the button is not being pressed, infinitly wait */
   while(!self MeleeButtonPressed())
      wait 0.05;
 
   /* Send a notify to client [turns on music]*/
   clientnotify("notify_stones");
 
   /* Show message on screen, then wait*/
   iPrintLnBold("^1Music On");
   wait 0.2;
 
   /* While the button is not pressed, continue to wait again */
   while(!self MeleeButtonPressed())
      wait 0.05;
 
   /* Send a notify to client [turn off music] */
   clientnotify("none");
 
   /* Show message and wait */
   iPrintLnBold("^1Music Off");
   wait 0.2;
}
Basically, the code is waiting UNTIL you press the melee button.

Pseudocode:
While the player is NOT pressing the button, wait until he presses the button.

Understand?

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 8:44 pm
by F |Madness| U
I understand it now thanks Drofder :) I think it was the layout of the code that put me off

Code: Select all

3.
while(!self MeleeButtonPressed())
 
4.
wait 0.05;
 
5.
clientnotify("notify_stones");
 
6.
iPrintLnBold("^1Music On");
 
7.
wait 0.2;
 
Made me think that whilst the melee button was not pressed, it would wait 0.05, then notify, then print, then wait 0.2, and repeat. I didn't realise the wait 0.05; was `linked` to the while argument.

One thing I've been wanting to know for a while is about creating new gametypes spefically for mods. Eg. codjumper mod used to run on "dm" but you then made it's own gametype "cj". What advantages are there of doing this and how might it be done? I notice that most mods have their own gametype.

Re: .gsc Scripting help needed

Posted: June 12th, 2011, 9:04 pm
by Drofder2004
The CJ Mod is just a renamed "DM".

Most of the benefits are aesthetics, having the "cj" gametype in a rotation, when you search servers you will see "cj" when loading the mod you will see the CJ mod title...

Other small (CoD4 at least) benefits are automatically created dvars, such as timelimits and scorelimits. These are not a major requirement for CJ as they already existed.

You latch your mod on to an existing gametype, ased on the gametype attributes.

DM - Free-For-All. No team based stuff.
TDM - Team based. No objectives.
SD - Team based. Objectives. Round based.
CTF - Team Based. Objectives. Not round based.
HQ - Team based. Objectives. Not round based. Dead-stay-dead.

I do not know a gametype off the top of my head, that does not have a base of one of the above.
E.g Zombies is probably TDM.