Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!
Moderator: Core Staff
-
XeloX
- CJ Newbie

- Posts: 74
- Joined: February 13th, 2010, 9:58 pm
Post
by XeloX » June 18th, 2011, 8:19 pm
so what i want is a script that works using my GUID and allows me to post messages to the whole server.
This is the script that i have so far but it does not read the clientdvar value. Works only in localhost mode
Code: Select all
  onPlayerConnect()
  {
    for(;;)
    {
     level waittill("connected", player);
     player thread onPlayerSpawned();
    }
  }
    Â
  onPlayerSpawned()
  {
    for(;;)
    {
     self waittill("spawned_player");
     if(self getGuid() == "--------------------")//Guid Here!
     {
       self thread check_dvars();
       self thread xelox();
     }
    }
  }
  Â
  check_dvars()
  {
      while(1)
      {
          if( getDvar( "mapsay" ) != "" )
              thread _mapsay();
          wait ( ( 0.05 / 20 ) * getDvarInt( "sv_fps" ) );
      }
  }
  Â
  Â
  _mapsay()
  {
      msg = getDvar( "mapsay" );
      setDvar( "mapsay", "" );
          players = getentarray("player", "classname");
      for(i = 0; i < players.size; i++)   Â
          players[i] playLocalSound( "bullet_impact_headshot_2" );   Â
      iPrintLnBold( msg );
  }
Â
So yes, can anybody help me? I cant seem to get it to work for the life if me. And yes i did load the dvar in the main section.

-
Drofder2004
- Core Staff

- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Post
by Drofder2004 » June 18th, 2011, 9:16 pm
1. Are you testing locally or on a dedi-server?
2. What is and what is not working? (Sound/Msg)
3. Are there any errors?
4. Place some debug prints.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
IzNoGoD
- CJ Worshipper

- Posts: 343
- Joined: January 6th, 2009, 8:39 pm
- Location: Netherlands/Holland
Post
by IzNoGoD » June 18th, 2011, 11:13 pm
XeloX wrote:so what i want is a script that works using my GUID and allows me to post messages to the whole server.
This is the script that i have so far but it does not read the clientdvar value. Works only in localhost mode
  onPlayerConnect()
  {
    for(;;)
    {
     level waittill("connected", player);
     player thread onPlayerSpawned();
    }
  }
    Â
  onPlayerSpawned()
  {
self endon("disconnect"); //add this line to make sure this stops if the player disconnects
//also: try to check guid on connect, and only run this thread if the guid is correct
//because guids cannot change while a player is on the server
    for(;;)
    {
     self waittill("spawned_player");
     if(self getGuid() == "--------------------")//Guid Here!
     {
       self thread check_dvars();
       self thread xelox();
     }
    }
  }
  Â
  check_dvars()
  {
self endon("disconnect"); //added this to prevent this thread from running after the player disconnects
self endon("spawned_player"); //added this to avoid duplicate threads (cod2 rcon spec bug double save/load msgs anyone?
)
      while(1)
      {
          if( getDvar( "mapsay" ) != "" )
//you cannot get a client cvar/dvar. Just check serversided. No need to check guids too then...
              thread _mapsay();
          wait ( ( 0.05 / 20 ) * getDvarInt( "sv_fps" ) );
//whats this shit? Just use either 0.05 or 1/getdvarint("sv_fps")
      }
  }
  Â
  Â
  _mapsay()
  {
      msg = getDvar( "mapsay" );
///again, you CAN NOT get client's dvars. Just check a serversided dvar. No need for guids
      setDvar( "mapsay", "" );
          players = getentarray("player", "classname");
      for(i = 0; i < players.size; i++)   Â
          players
playLocalSound( "bullet_impact_headshot_2" ); Â Â Â
      iPrintLnBold( msg );
  }
So yes, can anybody help me? I cant seem to get it to work for the life if me. And yes i did load the dvar in the main section.
Edit: removed ]code] tags to avoid disappearing of the colors 
LMGTFY!
Its not a glitch... Its the future!
-
Drofder2004
- Core Staff

- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Post
by Drofder2004 » June 18th, 2011, 11:22 pm
Failed to read text, didn't realise you were trying to send messages as a client and using DVARs.
The only way to do this is through menus or rcon.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
XeloX
- CJ Newbie

- Posts: 74
- Joined: February 13th, 2010, 9:58 pm
Post
by XeloX » June 19th, 2011, 10:48 am
Damn ok, well i guess ill give up on that then

Users browsing this forum: No registered users and 1 guest