[HELP] Complicated script for cod4

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
User avatar
XeloX
CJ Newbie
CJ Newbie
Posts: 74
Joined: February 13th, 2010, 9:58 pm

[HELP] Complicated script for cod4

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

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: [HELP] Complicated script for cod4

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.
Image
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
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: [HELP] Complicated script for cod4

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? :P)

            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!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: [HELP] Complicated script for cod4

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

User avatar
XeloX
CJ Newbie
CJ Newbie
Posts: 74
Joined: February 13th, 2010, 9:58 pm

Re: [HELP] Complicated script for cod4

Post by XeloX » June 19th, 2011, 10:48 am

Damn ok, well i guess ill give up on that then ;)
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest