Author |
Topic: mapping |
serthy |
General Member Since: Sep 8, 2010 Posts: 482 Last: Jun 28, 2013 [view latest posts] |
|
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
|
Tally |
General Member Since: Apr 21, 2005 Posts: 819 Last: Oct 26, 2012 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Aug. 16, 2011 04:33 pm |
|
explo32 writes...Quote: I made simple multiplayer map with wall and trigger_use_touch on it and compiled it. Then I made a gsc file:
Quote:
main()
{
maps\mp\_load::main();
ambientPlay("ambient_france");
game["allies"] = "american";
game["axis"] = "german";
game["attackers"] = "allies";
game["defenders"] = "axis";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";
maps\mp\_guid::main();
}
and put the script in another file:
Quote: main()
{
privateguid = d88108d8; // <----- make any guid you want.
thread cool(privateguid);
}
cool(pguid)
{
wall = getent("rawr","targetname");
walltrig = getent("rawrtrig","targetname");
while(1)
{
walltrig waittill("trigger", player);
checkguid = player getGuid();
if(checkguid == pguid)
{
wall hide();
wall notsolid();
wait 2;
wall show();
wall solid();
}
}
}
After I launched the map I got this error:
******* script compile error *******
uninitialised variable 'd88108d8': (file 'maps/mp/_guid.gsc', line 3)
privateguid = d88108d8; // <----- make any guid you want.
*
Then I changed the line
Quote: privateguid = d88108d8; // <----- make any guid you want.
to
Quote: privateguid = "d88108d8"; // <----- make any guid you want.
And now after I launch my map and I walk to the trigger I get this:
so it must be problem with this line:
Quote: walltrig waittill("trigger", player);
edited on Aug. 16, 2011 07:06 am by explo32
After opening console I can see these errors repeating all the time:
http://img829.imageshack.us/img829/74/plikm.jpg
The "variable is undefined" is probably caused by a timing issue - you are not giving the game enough time to set things up. Always put a wait time in a function if the function is being called before callback_startgametype has been completed.
This will probably get rid of the "variable is undefined" error:
Code: main()
{
wait( 0.65 );
thread cool( d88108d8 );
}
cool( pguid )
{
wall = getent( "rawr","targetname" );
walltrig = getent( "rawrtrig","targetname" );
if( isDefined( wall ) && isDefined( walltrig ) )
{
while( true )
{
walltrig waittill( "trigger", player );
if( isPlayer( player ) )
{
if( player getGuid() == pguid )
{
wall hide();
wall notsolid();
wait( 10 );
wall show();
wall solid();
}
}
}
}
}
NOTE 1: I think 2 seconds isn't enough time for a player to walk through an object. So, I gave the wait time 10 seconds instead.
NOTE 2: I still don't think this will work because the use of notsolid() in COD2 is restricted to certain clip brushes. Unless you have used the right one in your map, notsolid() will be useless. In COD4, notsolid() works on any script_brushmodel. |
|
|
|
IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
|
explo32 |
|
General Member Since: May 8, 2008 Posts: 67 Last: Jan 7, 2015 [view latest posts] |
|
|
|
serthy |
General Member Since: Sep 8, 2010 Posts: 482 Last: Jun 28, 2013 [view latest posts] |
|
|
|
|
BraX |
|
General Member Since: Apr 29, 2008 Posts: 413 Last: May 26, 2012 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Wednesday, Aug. 17, 2011 01:07 am |
|
I don't get why most peoples say that you need another GSC to add new function (like in idea with _guid.gsc). It all could be done in one script and three simple functions.
Code: main()
{
maps\mp\_load::main();
ambientPlay("ambient_france");
game["allies"] = "american";
game["axis"] = "german";
game["attackers"] = "allies";
game["defenders"] = "axis";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";
thread adminStuff();
}
adminStuff()
{
admins = getDvar( "sv_admins" ); // GUID1,GUID2,GUID3,GUID4 etc...
if( admins == "" )
return;
admins = toLower( admins );
thread wall();
while( 1 )
{
level waittill( "connected", player );
if( isSubStr( admins, player getGuid() ) )
player.isAdmin = true;
else
player.isAdmin = false;
}
}
wall()
{
wall = getent("rawr","targetname");
walltrig = getent("rawrtrig","targetname");
while(1)
{
walltrig waittill( "trigger", player );
if( !player.isAdmin )
continue;
wall hide();
wall notsolid();
wait 2;
wall show();
wall solid();
}
}
Oh.. i forgot to mention one thing... Creating forum thread called "mapping" which is about scripting is stupid.
Now feel free to click button called " SOLVED". |
|
|
|
explo32 |
|
General Member Since: May 8, 2008 Posts: 67 Last: Jan 7, 2015 [view latest posts] |
|
|
|
IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Wednesday, Aug. 17, 2011 10:48 am |
|
BraX writes...Quote: I don't get why most peoples say that you need another GSC to add new function (like in idea with _guid.gsc). It all could be done in one script and three simple functions.
Code: main()
{
maps\mp\_load::main();
ambientPlay("ambient_france");
game["allies"] = "american";
game["axis"] = "german";
game["attackers"] = "allies";
game["defenders"] = "axis";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";
thread adminStuff();
}
adminStuff()
{
admins = getDvar( "sv_admins" ); // GUID1,GUID2,GUID3,GUID4 etc...
if( admins == "" )
return;
admins = toLower( admins );
thread wall();
while( 1 )
{
level waittill( "connected", player );
if( isSubStr( admins, player getGuid() ) )
player.isAdmin = true;
else
player.isAdmin = false;
}
}
wall()
{
wall = getent("rawr","targetname");
walltrig = getent("rawrtrig","targetname");
while(1)
{
walltrig waittill( "trigger", player );
if( !player.isAdmin )
continue;
wall hide();
wall notsolid();
wait 2;
wall show();
wall solid();
}
}
Oh.. i forgot to mention one thing... Creating forum thread called "mapping" which is about scripting is stupid.
Now feel free to click button called " SOLVED".
Please, use strtok instead of issubstr().
Also, issubstr doesnt work on getguid(), as it is comparing numbers with a string. |
|
|
|
Tally |
General Member Since: Apr 21, 2005 Posts: 819 Last: Oct 26, 2012 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Wednesday, Aug. 17, 2011 12:19 pm |
|
IzNoGoD writes...Quote:
Please, use strtok instead of issubstr().
Also, issubstr doesnt work on getguid(), as it is comparing numbers with a string.
No, not true. If you don't believe me, check out Openwarfare mod for COD4 _advancedacp.gsc where isSubStr() is used to check a Dvar containing admin GUIDs against self getGuid(). It works fine. |
|
|
|