Search the Community
Showing results for tags 'ue3 script'.
-
The script below is working as expected, all variables get replicated to player in game on change, except that the default variables get replicated to users that join the game, instead of the current ones. I think that i need to create a function that is executed on the clients from new players, so it will get the variables from the server, but have no idea how to do it. Does anybody have an idea how to complete this replication ? The variables are : var RepNotify string RefArrayStatus [4]; var RepNotify int RefArrayAccessLevel [4]; // ***************************************************************************** // * * * * * * * * * * Rx_Mutator_AdminTool_Controller * * * * * * * * * * * * // Written by Ukill, Supported by ........................................... // ***************************************************************************** class Rx_Mutator_AdminTool_Controller extends Rx_Controller; //General var var string RefArrayName [4]; //ReferenceNameArray var string RefArrayDescription [4]; //ReferenceDescriptionArray var RepNotify string RefArrayStatus [4]; //ReferenceStatusArray var RepNotify int RefArrayAccessLevel [4]; //ReferenceAccessLevelArray var bool OSA; //OneStepAuthentication var int ArrayLength; var bool DebugMode; replication { if (bNetDirty && Role == ROLE_Authority) RefArrayStatus,RefArrayAccessLevel; } exec function AdminTool(string sToggleName, optional string sStatus, optional string iAccessLevel) { local string sStatusOut; local string iAccessLevelOut; local int x; local int y; //Filter bad sToggleName for (x = 0; x < ArrayLength ; x++) { if (RefArrayName[x] != sToggleName) { y=y++; if (y == ArrayLength) { sToggleName=""; sStatus=""; iAccessLevel=""; } } } // Swap if order is different if ( Len(sStatus) == 1 && Len(iAccessLevel) == 0 ) { iAccessLevel=(sStatus); sStatus="Skip"; } else if ( Len(iAccessLevel) > Len(sStatus) ) { sStatusOut=(iAccessLevel); (iAccessLevelOut)=(sStatus); iAccessLevel=(iAccessLevelOut); sStatus=(sStatusOut); } // Do status stuff if ( Len(iAccessLevel) == 0 && Len(sStatus) == 0 || "true" == sStatus || "false" == sStatus ) { ServerAdminToolStatus(sToggleName, sStatus); } //Do AccessLevel stuff if ( Len(iAccessLevel) == 1 && int(iAccessLevel) != 0 && int(iAccessLevel) > 0 && int(iAccessLevel) < 6) { ServerAdminToolAccessLevel(sToggleName, int(iAccessLevel)); } // Show summary if ( DebugMode == true ) { AdminToolInfo(); } } reliable server function ServerAdminToolStatus(string sToggleName, optional string sStatus) { local Rx_Mutator_AdminTool_Controller C; if ( DebugMode == true ) { ClientMessage("Started function ServerAdminToolAccessLevel with variables sToggleName: " $ sToggleName $ " sStatus: " $ sStatus); } /* * * * * * * * * * * * * * * * * * * * */ // DONT CHANGE - Start Authentication Check AdminToolAccessLevelAuth(RefArrayAccessLevel[0]); if (OSA == true && (RefArrayStatus[0]) == "true" ) { OSA=false; // DONT CHANGE - Stop Authentication Check /* * * * * * * * * * * * * * * * * * * * */ foreach WorldInfo.AllControllers(class'Rx_Mutator_AdminTool_Controller', C) { C.ServerAdminToolStatusDo(sToggleName, sStatus); } } else { foreach WorldInfo.AllControllers(class'Rx_Mutator_AdminTool_Controller', C) { ClientMessage(PlayerReplicationInfo.PlayerName $ " : You must be admin to use the ToggleStatus function"); } } } reliable server function ServerAdminToolAccessLevel(string sToggleName, int iAccessLevel) { local Rx_Mutator_AdminTool_Controller C; if ( DebugMode == true ) { ClientMessage("Started function ServerAdminToolAccessLevel with variables sToggleName: " $ sToggleName $ " iAccessLevel: " $ iAccessLevel); } /* * * * * * * * * * * * * * * * * * * * */ // DONT CHANGE - Start Authentication Check AdminToolAccessLevelAuth(RefArrayAccessLevel[0]); if (OSA == true && (RefArrayStatus[0]) == "true" ) { OSA=false; // DONT CHANGE - Stop Authentication Check /* * * * * * * * * * * * * * * * * * * * */ foreach WorldInfo.AllControllers(class'Rx_Mutator_AdminTool_Controller', C) { C.ServerAdminToolAccessLevelDo(sToggleName, iAccessLevel); } } else { foreach WorldInfo.AllControllers(class'Rx_Mutator_AdminTool_Controller', C) { ClientMessage(PlayerReplicationInfo.PlayerName $ " : You must be admin to use the ToggleAccessLevel function"); } } } exec function AdminToolInfo() { local int x; local string Msg; /* * * * * * * * * * * * * * * * * * * * */ // DONT CHANGE - Start Authentication Check AdminToolAccessLevelAuth(RefArrayAccessLevel[0]); if (OSA == true && (RefArrayStatus[0]) == "true" ) { OSA=false; // DONT CHANGE - Stop Authentication Check /* * * * * * * * * * * * * * * * * * * * */ ClientMessage(" "); ClientMessage(" Info: function AdminToolInfo"); ClientMessage(" "); ClientMessage(" Level: Status: Name: Description:"); ClientMessage(" "); for (x = 0; x < ArrayLength ; x++) { Msg = " " $ RefArrayAccessLevel[x] $ " " $ RefArrayStatus[x] $ " " $ RefArrayName[x] $ " " $ RefArrayDescription[x]; ClientMessage(Msg); } ClientMessage(""); } } function ServerAdminToolStatusDo(string sToggleName, optional string sStatus) // ToggleStatus Option: true,false,empty(autotoggle) { local int x; if ( DebugMode == true ) { ClientMessage("Started function ServerAdminToolStatusDo with variables sToggleName: " $ sToggleName $ " sStatus: " $ sStatus); } if ( DebugMode == true ) { ClientMessage("Jump in array with variable sToggleName: " $ sToggleName); } for (x = 0; x < ArrayLength ; x++) { if(sToggleName == RefArrayName[x] ) { if (sStatus == "true") { RefArrayStatus[x] = ("true"); if ( DebugMode == true ) ClientMessage( RefArrayStatus[x] $ " Found!" $ sToggleName ); } else if (sStatus == "false") { RefArrayStatus[x] = ("false"); if ( DebugMode == true ) ClientMessage( RefArrayStatus[x] $ " Found!" $ sToggleName ); } else if ("true" == RefArrayStatus[x] ) { RefArrayStatus[x] = ("false"); if ( DebugMode == true ) ClientMessage( RefArrayStatus[x] $ " Found!" $ sToggleName ); } else if ("false" == RefArrayStatus[x] ) { RefArrayStatus[x] = ("true"); if ( DebugMode == true ) ClientMessage( RefArrayStatus[x] $ " Found!" $ sToggleName ); } else { if ( DebugMode == true ) ClientMessage( RefArrayStatus[x] $ " None found!" $ sToggleName ); } } } } function ServerAdminToolAccessLevelDo(string sToggleName, int iAccessLevel){ local int x; if ( DebugMode == true ) { ClientMessage("Started function AdminToolAccessLevel with variables sToggleName: " $ sToggleName $ " iAccessLevel: " $ iAccessLevel); } for (x = 0; x < ArrayLength ; x++) { if( sToggleName == RefArrayName[x] ) { RefArrayAccessLevel[x] = (iAccessLevel); } } } function AdminToolAccessLevelAuth(int iAccessLevel) { local string GroupName; OSA=false; switch (iAccessLevel) { case 0: break; case 1: Groupname="None"; if (PlayerReplicationInfo.PlayerName == "") { OSA=true; } break; case 2: GroupName="All Users"; if (PlayerReplicationInfo.PlayerName != "") { OSA=true; } break; case 3: GroupName="Administrators"; if (PlayerReplicationInfo.bAdmin && PlayerReplicationInfo.PlayerName != "") { OSA=true; } break; case 4: GroupName="Developers"; if (PlayerReplicationInfo.PlayerName != "" && bIsDev) { OSA=true; } break; case 5: GroupName="Administrators or Developers"; if (PlayerReplicationInfo.bAdmin || bIsDev) { OSA=true; } break; } if ( OSA == true ) { ClientMessage( GroupName $ " Accepted with Level : " $ iAccessLevel ); } else if ( OSA == false ) { ClientMessage( GroupName $ " Denied with Level : " $ iAccessLevel ); } // Maybe later add here the modename in the clientmessage } defaultproperties { //General OSA=false DebugMode=false; //AuthMode=false; // AccessLevel 0 for None ArrayLength=4; // AccessLevel 1 for All Users // AccessLevel 2 for Administrators //ModeNames // AccessLevel 3 for Developers RefArrayName[0]="allmode"; RefArrayName[1]="mode1"; // RefArrayName (string) RefArrayName[2]="mode2"; // ModeNames : this variable is used to set the default Name for any Mode RefArrayName[3]="mode3"; // RefArrayStatus (string) //Modedescription // ModeStatus : This variable is used to set the default Status for any Mode. (false and False) RefArrayDescription[0]="All modes"; RefArrayDescription[1]="FutureSoldier"; // RefArrayAccessLevel (int) RefArrayDescription[2]="SandboxSpawn"; // Modesnames : This variable is used to set the default AccessLevel for any Mode. (0-4) RefArrayDescription[3]="SandboxGimme"; // TODO: create accesslevels that are static to users, for use in subfunctions //ModeStatus RefArrayStatus[0]="true"; RefArrayStatus[1]="true"; RefArrayStatus[2]="true"; RefArrayStatus[3]="true"; //ModeAccessLevel RefArrayAccessLevel[0]=2; RefArrayAccessLevel[1]=0; RefArrayAccessLevel[2]=0; RefArrayAccessLevel[3]=0; }
-
Can anybody tell me why this does not work online Offline it added an extra option to the VoteMenu. (Compiled file : Rx_Mutator_VoteMenu.u ) How do i get it to run on my server ? Rx_Mutator_VoteMenu : (Content) // ***************************************************************************** // * * * * * * * * * * * * Rx_Mutator_VoteMenu * * * * * * * * * * * * * * // ***************************************************************************** class Rx_Mutator_VoteMenu extends Rx_Mutator; event PreBeginPlay() { local Rx_VoteMenuHandler VoteMod; super.PreBeginPlay(); VoteMod=Rx_VoteMenuHandler(GetDefaultObject(Class'Rx_VoteMenuHandler')); VoteMod.VoteChoiceClasses[8] = class'Rx_VoteMenuChoice_ExtraChoice'; } final static function object GetDefaultObject(class ObjClass) { return FindObject(ObjClass.GetPackageName()$".Default__"$ObjClass, ObjClass); } defaultproperties { } Rx_VoteMenuChoice_ExtraChoice : (Content) // ***************************************************************************** // * * * * * * * * * Rx_VoteMenuChoice_ExtraChoice * * * * * * * * * * * * * * // ***************************************************************************** class Rx_VoteMenuChoice_ExtraChoice extends Rx_VoteMenuChoice; function Init() { ToTeam = Handler.PlayerOwner.PlayerReplicationInfo.Team.TeamIndex; Finish(); } function string ComposeTopString() { return super.ComposeTopString() $ " is calling for turn mode1"; } function Execute(Rx_Game game) { // Do something } DefaultProperties { PercentYesToPass=0.20f MenuDisplayString = "ExtraChoice" } I did found the code below, maybe it help to solve the problem : if(Rx_Controller(PlayerOwner) !=none && Rx_Controller(PlayerOwner).VoteHandler != none) { if(Rx_Controller(PlayerOwner).VoteHandler.VoteChoiceClasses.Length < (8+ExtraVoteNum)) { Rx_Controller(PlayerOwner).VoteHandler.VoteChoiceClasses.AddItem(class'RenX_CommanderMod.Rx_VoteMenuChoice_Commander'); //1 } }
-
Howto set replicated variable with unrealscript: Goals : (Create a var, that i can use to enable\disable functions ) 1. Set the "var (bool) bTestMode" 2. Change it with exec function 3. If "var (bool) bTestMode" changed on client\server -> replicate value to server\all other clients 4. (optional) Keep the "var (bool) bTestMode" alive between MapChange and when not Questions: 1. Are my goals possible\logical ? 2. Do I extend the class to the right class? (or can i better choose others ?) Content: The scripts does what i did planned, except that it does not change the same variable on other clients. For my question i created 2 files : - Rx_Mutator_TestMode.uc - Rx_Mutator_TestMode_Controller.uc File: Rx_Mutator_TestMode.uc (content) File: Rx_Mutator_Controller.uc (content) I would appriciate any solution.