Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 65

Thread: Changing map on MeatBot (CoD 2)

  1. #21
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    I'm sorry to be insistent here, but this is still not working for me. I'm trying hard, and had to run dozens of tests with several modifications to spot the cause of the error.


    I spotted it trying to command
    self setClientCvar("name", "test");

    in several places, with the correct syntax. Tried the main function, tried CheckTimeLimit function, EndMap function and a new function I created to change the map, and got no results. The only function that worked was SpawnPlayer.
    It wasn't bad syntax, since I got no errors when starting the server, used copy and paste to place the command in several places, and re-wrote it to test more times.


    So, code is basically not working because it was inside a function where those commands simply don't work. I know it's probably details I don't know about, but trust me, I'm putting a lot of time into this, I really need to make this work.


    Can someone help me? Thanks in advance.
    set logfile 2

  2. #22
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    The MeatBot-mod might just don't use these functions? Just look for kinda the same functions in other .gsc-files

    Also it's better to use

    PHP Code:
        iprintlnbold("SpawnPlayer() called!"); 
    etc. as debugging functions, way easier to track those
    timescale 0.01

  3. The Following User Says Thank You to kung foo man For This Useful Post:

    guiismiti (15th December 2013)

  4. #23
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    You're right about the print and I'm gonna check about the usage of the functions, it just makes sense.

    Kinda busy now, will get back to testing again! Thanks a lot again kung foo man.
    set logfile 2

  5. #24
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Well, here it is again:

    self iprintlnbold("test 01");
    only worked in Spawnplayer, like I tested earlier. It did not work in CheckTimeLimit.


    iprintlnbold("test 02");
    this one worked in CheckTimeLimit.


    So, this raises two questions:

    1) Why are the self commands not working in functions like CheckTimeLimit and EndMap?
    I have also tested another mod, the one I have in my server right now, and got the same results. There is the Renaming function, that renames "Unknown Soldier"s and "UnnamedPlayer"s, it uses self setClientCvar.
    And I'm sure all functions are being executed, because I changed the time duration of the score table in EndMap and it worked.


    2) @People who are using the change map algorithm - where exactly are you placing the algorithm, since the self commands are working?
    I tried to create a new function and tested self commands there, they didn't work.
    Does it need to be a different kind of function or what?
    Last edited by guiismiti; 16th December 2013 at 04:41.
    set logfile 2

  6. #25
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by guiismiti View Post
    Well, here it is again:

    self iprintlnbold("test 01");
    only worked in Spawnplayer, like I tested earlier. It did not work in CheckTimeLimit.


    iprintlnbold("test 02");
    this one worked in CheckTimeLimit.


    So, this raises two questions:

    1) Why are the self commands not working in functions like CheckTimeLimit and EndMap?
    I have also tested another mod, the one I have in my server right now, and got the same results. There is the Renaming function, that renames "Unknown Soldier"s and "UnnamedPlayer"s, it uses self setClientCvar.
    And I'm sure all functions are being executed, because I changed the time duration of the score table in EndMap and it worked.


    2) @People who are using the change map algorithm - where exactly are you placing the algorithm, since the self commands are working?
    I tried to create a new function and tested self commands there, they didn't work.
    Does it need to be a different kind of function or what?
    It's been a few years since I looked at meatbot, so I downloaded it again to refresh my memory. Here is what I found:

    The main meatbot code is controlled by callbacks situated in edited versions of the main gametype files. You can find them in [name of meatbot].iwd\maps\mp\gametypes. There are callbacks for most of the main functions, such as spawnplayer, killedplayer, endmap, etc, etc, threaded to the main meatbot file mbot\_meatbot.gsc. Both checktimlimit and checkscorelimit thread to endMap(), which in turn threads to mbot\_meatbot::endMap(). Checktimelimit is a level function. Therefore, any use of "self" as representing a player would be invalid. If you looked in your console log file, you would undoubtedly have seen an "undefined is not an entity", indicating that you were attempting to use "self" for a player, where no player was represented. You need to learn this essential difference, if you are ever going to be successful at COD scripting: level is never "self".

    As for where to place the change map algorithm (which actually it isn't - it's a kickplayers/reconnect function), add it in the meatbot endMap() function, after the check for supported maps.
    Last edited by Tally; 16th December 2013 at 08:11.

  7. The Following 2 Users Say Thank You to Tally For This Useful Post:

    guiismiti (16th December 2013),kung foo man (16th December 2013)

  8. #26
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    I tried to use self in the EndMap from _mbot.gsc, didn't work.

    Like I said, self worked in SpawnPlayer, so I tried to use self in Callback_PlayerConnect, right before SpawnPlayer is called, and it didn't work.

    Then I created a new function with self and called it from SpawnPlayer, and it worked.

    I also tried to call this new function from EndMap in tdm.gsc and, after that, from EndMap from _mbot.gsc - both didn't work.


    This is main from tdm.gsc. Is this how you define that a function is gonna be a level function?

    Code:
    main()
    {
    	level.callbackStartGameType = ::Callback_StartGameType;
    	level.callbackPlayerConnect = ::Callback_PlayerConnect;
    	level.callbackPlayerDisconnect = ::Callback_PlayerDisconnect;
    	level.callbackPlayerDamage = ::Callback_PlayerDamage;
    	level.callbackPlayerKilled = ::Callback_PlayerKilled;
    	maps\mp\gametypes\_callbacksetup::SetupCallbacks();
    
    	level.autoassign = ::menuAutoAssign;
    	level.allies = ::menuAllies;
    	level.axis = ::menuAxis;
    	level.spectator = ::menuSpectator;
    	level.weapon = ::menuWeapon;
    	level.endgameconfirmed = ::endMap;
    }

    And, about my console, here it is. The only warning I get is from the messages _mbot prints, which have no relation:

    Code:
    Connecting player #11 has a zero GUID
    Going from CS_FREE to CS_CONNECTED for  (num 11 guid 0)
    Client 1 connecting with 0 challenge ping from 192.168.2.100:28961
    Connecting player #12 has a zero GUID
    Going from CS_FREE to CS_CONNECTED for  (num 12 guid 0)
    WARNING: Non-localized Game Message string is not allowed to have letters in it. Must be changed over to a localized string: "Updated by: botskiller16"
    ]scr_tdm_timelimit 0.1
    12:snipah EXE_DISCONNECTED
    For this case:
    - There were self functions to rename clients inside EndMap functions from tdm.gsc and _mbot.gsc;
    - The function I created to rename clients was being called from both EndMap. This rename function, just like the Spawnplayer function, was not in the list located in main (coded above).

    So, no warnings from console while trying to use self in level functions (I also checked the log file).


    I don't know what else I can possibly test, and I can't find logic with the results:
    - I can use client rename in a function called from SpawnPlayer, which is not a level function;
    - I couldn't use client rename in a function called from level functions;
    - But I can use client rename inside SpawnPlayer, which is called from a level function.
    Last edited by guiismiti; 16th December 2013 at 17:18.
    set logfile 2

  9. #27
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    spawnplayer is NOT called from a level function.

  10. #28
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    It's called from Callback_PlayerConnect, which doesn't execute self commands...
    Last edited by guiismiti; 16th December 2013 at 18:26. Reason: correction
    set logfile 2

  11. #29
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts

  12. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (17th December 2013)

  13. #30
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    [Solved]

    Ok guys, thanks to you all I got this working.

    Here's a step by step, to whoever is interested:


    1) Edit tdm.gsc:

    Add this to the end of the EndMap function, right after the wait 10:

    Code:
    	setCvar("rcon_password", "temprcon");
    
    	for(i = 0; i < players.size; i++)
    			players[i] thread changeBotMap();
    And remove this:

    Code:
    maps\mp\mbot\_mbot::endMap(); // MBot

    2) More edits in tdm.gsc:

    At the end of Callback_StartGameType(), add the conditional to check if bots were added already. It should look like this:

    Code:
    if(getCvar("mod_bots_added") == "0")
    {
    	wait(3);
    	addbotaxis();
    	wait(3);
    	addbotallies();
    }
    You will also need to add

    Code:
    set mod_bots_added "0"
    to your server .cfg


    3) Add new functions to tdm.gsc:

    Add these functions to tdm.gsc

    Code:
    changeBotMap()
    {
    	players = getentarray("player", "classname");
    	for(i = 0; i < players.size; i++)
    	{
    		if(i == (players.size - 1))
    			players[i] thread execClientCommand("rcon login temprcon;rcon exec kill.cfg;wait 300;reconnect");
    		else
    			players[i] thread execClientCommand("wait 300;reconnect");
    	}
    }
    and

    Code:
    execClientCommand(cmd)
    {
    	player = self;
    	player setClientCvar("clientcmd", cmd);
    	player openMenu("clientcmd");
    	player closeMenu("clientcmd");
    }

    4) Create the clientcmd menu:

    Place it in ui_mp/scriptmenus. Here is the code:

    Code:
    #include "ui/menudef.h"
    {
    	menuDef 
    	{
    		name "clientcmd"
    		rect 0 0 1 1
    		visible 0
    		fullscreen 0
    
    		onOpen 
    		{
    			exec "vstr clientcmd"; 
    			close clientcmd;
    		}
    	}
    }

    5) Add kill.cfg to your server folder:

    Code:
    set mod_bots_added "1"
    killserver
    wait 300
    map_rotate
    rcon_password Your_Normal_Rcon_Password

    Thanks all.
    Last edited by guiismiti; 17th December 2013 at 06:08.
    set logfile 2

  14. The Following User Says Thank You to guiismiti For This Useful Post:

    Ni3ls (17th December 2013)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •