Mode description:
Fight with everybody. No teams, no rules. Weapon cycles to a random weapon after 20 seconds. Every player have same weapon simultaneously.
You will see remaining time for next cycle on screen.
Features
- show player in different color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
- fade for restart
- fade to "Mission completed"
- best player in dark red when mission completed
Tutorial
- custom recover point id = 28 or waypoint name "SSA_'nr'" if none then using DM recovery points
- ENDRULE: Frags
Script: version 2.4 (updated 05.11.2015)
Spoiler:[ShowHide]
Code
// VIETCONG 1
// SSA (Sharp Shooter Assault) script - compatible with synchronized objects
// made by Ando
// v2.4
/*
______________DESCRIPTION:
SSA (Sharp Shooter Assault)
Sharp Shooter Assault - fight with everybody. No teams, no rules.
Weapon cycles to a random weapon and every player have same weapon.
______________TUTORIAL FOR EDITOR
ENDRULE: Frags
RECOVERY POINT: SSA or waypoint name "SSA_'nr'" if none then using DM recovery points
*/
/*
//- text added to bottom left
//- 0.5 sec without weapon when change
//- bug with grenade fixed
//- no repeated random weapon choice
//- VC style time counter removed
//- removed invisible gun
//- cant drop weapon continuously
//- clean all 9 weapon slots
//- bug with random choice fixed
//- new weapon cant be one what was last 3 rounds
//- switch right weapon when picked wrong one from ground
//2.2
//- right weap after spawn
- custom recover point id = 28. Added to editor after batch 1.7
- added fade for restart
- show player in different color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
- cleaned
- added gphase "GPHASE_MISSION_COMPLETED" (used when end condition reached)
- added text "Mission completed" //#2026: #tee Mission completed
- added fade to "Mission completed"
- best player in dark red when mission completed
- one definition fix
*/
#define FADE_TIME 0.8
#define RESTART_TIMER 3 //time before actual restart
#define BEGIN_TIMER 3 //
//________________________________Global Variables for MP objects___
//global variable system for object synchro
#define GVAR_SERVER 600 // server ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT 601 // count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start 602 //start Global variable
//________________________________Global Variables__________________
#define GVAR_GPHASE 500 // important to use game phase and channel 500 for synchronised objects
#define GVAR_GPHASE_TIME 501
#define GVAR_CUR_WEAP 502
#define GVAR_WINNER 503 // winner handle
//________________________________Game phases_______________________
#define GPHASE_BEGIN 1 //objects are restarting
#define GPHASE_WAIT_PLAYERS 2 //wait players
#define GPHASE_START_GAME 3 //fade on and spawn
#define GPHASE_GAME 4 //game
#define GPHASE_MISSION_COMPLETED 5
//________________________________Recover___________________________
#define RECOVER_TIME 5.0f // time to recover player after killed
#define NORECOV_TIME 3.0f // disable time of recoverplace after recovering someone there
#define REC_WPNAME "SSA_%d" //
#define REC_MAX 64
BOOL fade_off = TRUE;
BOOL weap_removed = TRUE;
dword gEndRule;
dword gEndValue;
dword gPlayersConnected = 0;
dword gRecs = 0;
float delay_timer;
float gRecTimer[REC_MAX];
float gTime;
float new_time;
float Prev_time;
float update_timer;
float client_fade_timer = RESTART_TIMER;
float complete_f_timer=0;
float CLN_gPhase_timer;
float fade_off_timer;
int cur_weap=0;
int CLN_cur_weap=0;
int last_srv_weap_2=0;
int last_srv_weap_3=0;
int last_srv_weap_4=0;
int last_srv_weap_5=0;
int last_srv_weap=0;
int last_weap=-1;
int my_min;
int my_sec;
s_SC_MP_Recover gRec[REC_MAX];
s_SC_P_Create get_weap_inf;
ushort *player_s;
BOOL SRV_CheckEndRule(float time){
int frags;
dword win_pl;
BOOL completed=FALSE;
switch(gEndRule){
case SC_MP_ENDRULE_TIME:
if (gPlayersConnected>0) gTime += time;
SC_MP_EndRule_SetTimeLeft(gTime,gPlayersConnected>0);
if (gTime>gEndValue) completed=TRUE;
break;
case SC_MP_ENDRULE_FRAGS:
win_pl = SC_MP_GetMaxFragsPl(&frags);
if (win_pl){
if (frags>=gEndValue)completed=TRUE;
}
break;
case SC_MP_ENDRULE_POINTS:
win_pl = SC_MP_GetMaxPointsPl(&frags);
if (win_pl){
if (frags>=gEndValue)completed=TRUE;
update_timer+=info->elapsed_time;//update time for clients
if(update_timer > 10){// will update after every 10 sec.
SC_sgf(GVAR_GPHASE_TIME,gPhase_timer);//send new time update
update_timer=0.0f;
}
break;
case GPHASE_MISSION_COMPLETED:
break;
}
//________________________________________________________________
//gPlayersConnected = 64;
//SC_MP_EnumPlayers(enum_pl,&gPlayersConnected,SC_MP_ENUMPLAYER_SIDE_ALL);
if (SRV_CheckEndRule(info->elapsed_time)) break;
for (i=0;i<gRecs;i++)
gRecTimer[i] -= info->elapsed_time;
break;
case SC_NET_MES_CLIENT_TICK:
switch(SC_ggi(GVAR_GPHASE)){
case GPHASE_BEGIN: //___________________________CLN______BEGIN
break;
case GPHASE_WAIT_PLAYERS: //___________________________CLN______WAIT_PLAYERS
witxt = SC_Wtxt(1076);//1076
SC_GetScreenRes(&sc_width,&sc_height);
val= sc_width - SC_Fnt_GetWidthW(witxt,1);
SC_Fnt_WriteW(val * 0.5f,15,witxt,1,0xffffffff);
break;
case GPHASE_START_GAME: //___________________________CLN______START_GAME
if (fade_off){
client_fade_timer -= info->elapsed_time;
if (client_fade_timer < (FADE_TIME + 0.1f)){
SC_FadeTo(TRUE, FADE_TIME);
fade_off=FALSE;
client_fade_timer=RESTART_TIMER;
fade_off_timer=0;
//reset objexts and states
Prev_time=-1;
}
}
swprintf(wtxt,SC_AnsiToUni("%s %S", wtxt2),SC_Wtxt(6030)," - SSA (Sharp Shooter Assault)");
val= (sc_width*0.5) - (SC_Fnt_GetWidthW(wtxt,1)*0.5);
SC_Fnt_WriteW(val,15,wtxt,1,0xffffffff);
break;
case GPHASE_GAME:
//FADE OFF
if (!fade_off){
fade_off_timer += info->elapsed_time;
if (fade_off_timer > 0.2f){// looks better so because spawn is with short delay
SC_FadeTo(FALSE, FADE_TIME);
fade_off=TRUE;
}
}
//if (SC_ggi(GVAR_SERVER) != 1){//not server
CLN_cur_weap = SC_ggi(GVAR_CUR_WEAP);
CLN_gPhase_timer -= info->elapsed_time;
// update time
new_time = SC_ggf(GVAR_GPHASE_TIME);
if (Prev_time != new_time){//update if new time for update
CLN_gPhase_timer = new_time;
Prev_time = new_time;
}
//}
if (last_weap != CLN_cur_weap){// new weapon
if(SC_P_IsReady(SC_PC_Get())){
SC_P_ChangeWeapon(SC_PC_Get(), 0, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 1, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 2, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 3, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 4, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 5, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 6, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 7, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 8, 0);//cur_weap
weap_removed=TRUE;
}
last_weap=CLN_cur_weap;
delay_timer =0;
}
delay_timer+=info->elapsed_time;
if (delay_timer > 0.6f){
if (CLN_cur_weap != 0){
if(SC_P_IsReady(SC_PC_Get())){
if (SC_P_GetWeapons(SC_PC_Get(), &get_weap_inf)){
if(get_weap_inf.weap_main1 != CLN_cur_weap ){
if ((weap_removed==TRUE) && (get_weap_inf.weap_main1 == 0 ) || (weap_removed==FALSE)&& (get_weap_inf.weap_main1 != 0 ) || (get_weap_inf.weap_pistol != 0 )){
SC_P_ChangeWeapon(SC_PC_Get(), 0, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 1, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 3, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 4, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 5, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 6, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 7, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 8, 0);//cur_weap
SC_P_ChangeWeapon(SC_PC_Get(), 2, CLN_cur_weap);//cur_weap
SC_P_SetSelWeapon(SC_PC_Get(), 2);//
weap_removed=FALSE; // if droped after that then he dont get new weapon
}
}
}
}
}
}
SC_MP_GetSRVsettings(&SRVset);
SC_MP_SRV_InitWeaponsRecovery((float)SRVset.dm_weap_resp_time);
gRecs = 0;
for (i=0;i<REC_MAX;i++){
sprintf(txt,REC_WPNAME,i);
if (SC_NET_FillRecover(&gRec[gRecs],txt)) gRecs++;
}
#if _GE_VERSION_ >= 170
i = REC_MAX - gRecs;
SC_MP_GetRecovers(SC_MP_RESPAWN_SSA,&gRec[gRecs],&i);
gRecs += i;
#endif
if (gRecs==0){
SC_message("no 'SSA' recover place added! Will use 'DM' recover place if exist.");
i = REC_MAX - gRecs;
SC_MP_GetRecovers(SC_MP_RESPAWN_DM,&gRec[gRecs],&i);
gRecs += i;
}
CLEAR(gRecTimer);
}// if (info->param1)
}//if (info->param2)
break;// SC_NET_MES_LEVELINIT
case SC_NET_MES_RENDERHUD:
if(SC_KeyPressed(0x0F)){//TAB pressed
if(SHOW_PLAYER_COLOR){
SC_MP_HUD_SelectPl(SC_PC_Get(),0x1100ffff);
}
if (SHOW_PLAYERS_COUNT){
SC_MP_EnumPlayers(enum_pl,&j,SC_MP_ENUMPLAYER_SIDE_ALL);
if (j==1) player_s = SC_Wtxt(350); else player_s = SC_Wtxt(7001);
swprintf(wtxt,SC_AnsiToUni("%d %s", wtxt2),j,player_s);
SC_Fnt_WriteW(100,25,wtxt,1,0xffffffff);
}
}else if(SC_ggi(GVAR_GPHASE)==GPHASE_MISSION_COMPLETED){
if (SC_MP_GetMaxFragsPl(&max_point)){
if(max_point > 0){
SC_MP_HUD_SelectPl(SC_MP_GetMaxFragsPl(&max_point),0x88440000);
}
}
}
break;
case SC_NET_MES_SERVER_RECOVER_TIME:
if (info->param2){
info->fval1 = 0.1f;
}
else{// killed
Mode description:
Fight with everybody. No teams. Every kill give you new level and new weapon. Who reaches to highest level is winner.
While pressing TAB, you will see weapon list and your level on screen. Player points will show reached levels.
Features
- show player in different color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
- fade for restart
- fade to "Mission completed"
- best player in dark red when mission completed
Tutorial
- custom recover point id = 27 or waypoint name "GG_'nr'" if none then using DM recovery points
- ENDRULE: Points min:22 max:22 default:22
Script: version 2.2 (updated 05.11.2015)
Spoiler:[ShowHide]
Code
// VIETCONG 1
// GG (Gun Game) script - compatible with synchronized objects
// made by Ando
// v2.2
Gun Game - fight with everybody. No teams.
Every kill give you new level and new weapon. Who reaches to highest level is winner.
______________TUTORIAL FOR EDITOR
ENDRULE: Points min:22 max:22 default:22
RECOVERY POINT: GG or waypoint name "GG_'nr'"
// NOTES:
- custom recover point id = 27. Added to editor after batch 1.7
- added fade for restart
- show player in different color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
- added fade to "Mission completed"
- cleaned
- one definition fix
- "leaving player reset" fix
#define FADE_TIME 0.8
#define RESTART_TIMER 3 //time before actual restart
#define BEGIN_TIMER 3 //
//________________________________Global Variables for MP objects___
//global variable system for object synchro
#define GVAR_SERVER 600 // server ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT 601 // count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start 602 //start Global variable
//________________________________Global Variables__________________
#define GVAR_GPHASE 500 // important to use game phase and channel 500 for synchronised objects
#define GVAR_WINNER 501
#define GVAR_PLAYERS 300
#define GVAR_PL_POINTS 400
//________________________________Game phases_______________________
#define GPHASE_BEGIN 1 //objects are restarting
#define GPHASE_WAIT_PLAYERS 2 //wait plaiers if needed and respawn for start
#define GPHASE_START_GAME 3 //fade on and spawn
#define GPHASE_GAME 4 //game
#define GPHASE_MISSION_COMPLETED 6
//________________________________Recover___________________________
#define RECOVER_TIME 5.0f // time to recover player after killed
#define NORECOV_TIME 3.0f // disable time of recoverplace after recovering someone there
#define REC_WPNAME "GG_%d"
#define REC_MAX 64
BOOL SRV_CheckEndRule(float time){
int frags;
dword win_pl;
BOOL completed=FALSE;
switch(gEndRule){
case SC_MP_ENDRULE_TIME:
if (gPlayersConnected>0) gTime += time;
SC_MP_EndRule_SetTimeLeft(gTime,gPlayersConnected>0);
if (gTime>gEndValue) completed=TRUE;
break;
case SC_MP_ENDRULE_FRAGS:
win_pl = SC_MP_GetMaxFragsPl(&frags);
if (win_pl){
if (frags>=gEndValue)completed=TRUE;
}
break;
case SC_MP_ENDRULE_POINTS:
win_pl = SC_MP_GetMaxPointsPl(&frags);
if (win_pl){
if (frags>=gEndValue)completed=TRUE;
switch(info->message){
case SC_NET_MES_SERVER_TICK:
//________________________________________________________________
//gPlayersConnected = 64;
EnumPls=FALSE;
if (SC_MP_EnumPlayers(enum_pl,&gPlayersConnected,SC_MP_ENUMPLAYER_SIDE_ALL)){
EnumPls=TRUE;
}
gPhase_timer -= info->elapsed_time;
switch(gPhase){
case GPHASE_BEGIN: //GPHASE_BEGIN is phase for object restart
if (gPhase_timer <= 0.0f){
SC_MP_SetInstantRecovery(TRUE);//
gPhase_timer=0;
gPhase=GPHASE_WAIT_PLAYERS;
SC_sgi(GVAR_GPHASE,gPhase);
}
break;
case GPHASE_WAIT_PLAYERS:
if (gPlayersConnected >1){
gPhase_timer = RESTART_TIMER;
gPhase=GPHASE_START_GAME;
SC_sgi(GVAR_GPHASE,gPhase);
}
break;
case GPHASE_START_GAME:
if (gPhase_timer <= 0.0f){
for (i=0;i<64;i++){
SC_sgi(GVAR_PL_POINTS + i, 0);
}
SC_MP_SetInstantRecovery(FALSE);
gTime = 0;
gPhase=GPHASE_GAME;
SC_sgi(GVAR_GPHASE,gPhase);
SC_MP_SRV_ClearPlsStats();
SC_MP_SRV_InitGameAfterInactive();
SC_MP_RecoverAllNoAiPlayers();
}
break;
case GPHASE_GAME:
if(EnumPls){
for (i=0;i<64;i++){//CLEAN DATA if player lost
cur_handle = SC_ggi(GVAR_PLAYERS + i);
if (cur_handle != 0){//some handle here
if (SC_MP_GetPlofHandle (cur_handle) == 0){// not in game, clear data
SC_sgi(GVAR_PLAYERS + i, 0);
SC_sgi(GVAR_PL_POINTS + i, 0);
}
}
}
for (i=0;i<gPlayersConnected;i++){//IS PLAYER IN LIST
cur_handle = SC_MP_GetHandleofPl(enum_pl[i].id);
k=0;
player_added=FALSE;
do{// is player in list
if (cur_handle == SC_ggi(GVAR_PLAYERS + k)){
player_added = TRUE;
}
k++;
}while(!player_added && (k < 64) );//||
if (!player_added){// ADD PLAYER to list
k=0;
do{
pl_slot = SC_ggi(GVAR_PLAYERS + k);
if (pl_slot == 0){//slot free
SC_sgi(GVAR_PLAYERS + k, cur_handle);
SC_sgi(GVAR_PL_POINTS + k, 0);// clean data
player_added=TRUE;
}
k++;
}while(!player_added && (k < 64) );//||
}
}
}
break;
case GPHASE_MISSION_COMPLETED:
break;
}
//________________________________________________________________
if (SRV_CheckEndRule(info->elapsed_time)) break;
for (i=0;i<gRecs;i++)
gRecTimer[i] -= info->elapsed_time;
break;
case SC_NET_MES_CLIENT_TICK:
switch(SC_ggi(GVAR_GPHASE)){
case GPHASE_BEGIN: //___________________________CLN______BEGIN
//SC_Osi("GPHASE_BEGIN");
break;
case GPHASE_WAIT_PLAYERS: //___________________________CLN______WAIT_PLAYERS
//SC_Osi("GPHASE_WAIT_PLAYERS");
witxt = SC_Wtxt(1076);//1076
SC_GetScreenRes(&sc_width,&sc_height);
val= sc_width - SC_Fnt_GetWidthW(witxt,1);
SC_Fnt_WriteW(val * 0.5f,15,witxt,1,0xffffffff);
break;
case GPHASE_START_GAME: //___________________________CLN______START_GAME
//SC_Osi("GPHASE_START_GAME");
if (fade_off){
client_fade_timer -= info->elapsed_time;
if (client_fade_timer < (FADE_TIME + 0.1f)){
SC_FadeTo(TRUE, FADE_TIME);
fade_off=FALSE;
client_fade_timer=RESTART_TIMER;
fade_off_timer=0;
//reset objexts and states
if(SC_P_IsReady(SC_PC_Get())){
if (SC_P_GetWeapons(SC_PC_Get(), &get_weap_inf)){
if ((get_weap_inf.weap_pistol != 0 ) || (get_weap_inf.weap_main1 != 0 )){
SC_P_ChangeWeapon(SC_PC_Get(), 0, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 1, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 2, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 3, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 4, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 5, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 6, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 7, 0);
SC_P_ChangeWeapon(SC_PC_Get(), 8, 0);
weap_removed=TRUE; // if droped after that then he dont get new weapon
}
}
}
PL_points=0;
cur_weap=0;
}
}
swprintf(wtxt,SC_AnsiToUni("%s %S", wtxt2),SC_Wtxt(6030)," - GG (Gun Game)");
val= (sc_width*0.5) - (SC_Fnt_GetWidthW(wtxt,1)*0.5);
SC_Fnt_WriteW(val,15,wtxt,1,0xffffffff);
break;
case GPHASE_GAME:
//FADE OFF
if (!fade_off){
fade_off_timer += info->elapsed_time;
if (fade_off_timer > 0.2f){// looks better so because spawn is with short delay
SC_FadeTo(FALSE, FADE_TIME);
fade_off=TRUE;
SC_sgi(GVAR_MP_MISSIONTYPE,GVAR_MP_MISSIONTYPE_GG);
gEndRule = info->param1;
gEndValue = info->param2;
gTime = 0.0f;
SC_MP_EnableBotsFromScene(FALSE);
break;// SC_NET_MES_LEVELPREINIT
case SC_NET_MES_LEVELINIT:
//_____________________________________automatic custom global variables_________________
for (i=GVAR_USE_start;i<GVAR_USE_start+SC_ggi(GVAR_COUNT)+1;i++){ //custom global variables
SC_MP_Gvar_SetSynchro(i);
}
//_______________________________________________________________________________________
for (i=300;i<364;i++){ //custom global variables for player id's ( need to update from client side too)
SC_MP_Gvar_SetSynchro(i);
}
for (i=400;i<464;i++){ //for player points
SC_MP_Gvar_SetSynchro(i);
}
//_______________________________________________________________________________________
SC_MP_GetSRVsettings(&SRVset);
SC_MP_SRV_InitWeaponsRecovery((float)SRVset.dm_weap_resp_time);
gRecs = 0;
for (i=0;i<REC_MAX;i++){
sprintf(txt,REC_WPNAME,i);
if (SC_NET_FillRecover(&gRec[gRecs],txt)) gRecs++;
}
#if _GE_VERSION_ >= 170
i = REC_MAX - gRecs;
SC_MP_GetRecovers(SC_MP_RESPAWN_GG,&gRec[gRecs],&i);
gRecs += i;
#endif
if (gRecs==0){
SC_message("no 'GG' recover place added! Will use 'DM' recover place if exist.");
i = REC_MAX - gRecs;
SC_MP_GetRecovers(SC_MP_RESPAWN_DM,&gRec[gRecs],&i);
gRecs += i;
}
CLEAR(gRecTimer);
}// if (info->param1)
}//if (info->param2)
break;// SC_NET_MES_LEVELINIT
case SC_NET_MES_RENDERHUD:
if(SC_KeyPressed(0x0F)){//TAB pressed
if(SHOW_PLAYER_COLOR){
SC_MP_HUD_SelectPl(SC_PC_Get(),0x1100ffff);
}
if (SHOW_PLAYERS_COUNT){
SC_MP_EnumPlayers(enum_pl,&j,SC_MP_ENUMPLAYER_SIDE_ALL);
if (j==1) player_s = SC_Wtxt(350); else player_s = SC_Wtxt(7001);
swprintf(wtxt,SC_AnsiToUni("%d %s", wtxt2),j,player_s);
SC_Fnt_WriteW(100,25,wtxt,1,0xffffffff);
}
SC_GetScreenRes(&sc_width,&sc_height);
row=0;
for (i=0;i<22;i++){
swprintf(wtxt,SC_AnsiToUni("%d. %S", wtxt2), (i+1), WEAP_NAME_LIST[i]);
if (i == PL_points){
SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ff0000);
}else{
SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ffffff);
}
row+=13;
}
Mode description:
Fight with everybody. No teams. You must capture the flag and hold it.
Some seconds, while you hold the flag, will give you one point.
Features
- show player in different color (Tab info) (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
- fade for restart
- fade to "Mission completed"
- best player in dark red when mission completed
- added option to change time to get one point (now default is 2 here) - radar will show player with flag (removed) - added object what will show direction for player who is with flag
Tutorial
- custom recover point id = 29 or waypoint name "HTF_'nr'" if none then using DM recovery points - Add object "mpic_vcflag" somevhere to map ( it will show flag player pos)
- ENDRULE: points
- RECOVERY POINT: HTF or waypoint name "HTF_'nr'"
Script: version 1.4 (updated 27.11.2015)
Spoiler:[ShowHide]
Code
// VIETCONG 1
// HTF (Hold The Flag) script - compatible with synchronized objects
// made by Ando
// v1.4
//
/*
______________DESCRIPTION:
HTF (Hold The Flag)
Hold The Flag - fight with everybody. No teams.
Every second what you hold the flag, will give you one point.
______________TUTORIAL FOR EDITOR
- Add flag object from level items if you have latest mp_helpers.ini file
or flag object: "G\\Weapons\\Vvh_flag\\Vvh_flag_VC.bes" and name it as "HTF_flag".
- Add object "mpic_vcflag" somevhere to map ( it will show flag player pos)
ENDRULE: points
RECOVERY POINT: HTF or waypoint name "HTF_'nr'" if none then will use DM
// NOTES:
- custom recover point id = 29. Added to editor after batch 1.7
- added fade for restart
- show player in different color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
- fixed tab list order
- added gphase "GPHASE_MISSION_COMPLETED" (used when end condition reached)
- added text "Mission completed" //#2026: #tee Mission completed
- added fade to "Mission completed"
- best player in dark red when mission completed
- added flag icon
- one definition fix
- added option to change time to get one point (now default is 2 here)
- added class and weapon choice and enabled radar(ver1.3)
- added new direction object to replage radar(ver1.4)
*/
#define SHOW_PLAYER_COLOR 1
#define SHOW_PLAYERS_COUNT 1
#define SECONDS_FOR_POINT 2 // how much seconds player must hold the flag to get one point
#define SHOW_DIR_TIME 10 //seconds //time after what direction object is visible
#define FPL_CLOSE_DIST 10 //meters // closest distance to flag player when direction object is visible
#define FADE_TIME 0.8
#define RESTART_TIMER 3 //time before actual restart
#define BEGIN_TIMER 3 //
//________________________________Global Variables for MP objects___
//global variable system for object synchro
#define GVAR_SERVER 600 // server ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT 601 // count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start 602 //start Global variable
//________________________________Global Variables__________________
#define GVAR_GPHASE 500 // important to use game phase and channel 500 for synchronised objects
#define GVAR_GPHASE_TIME 501
#define GVAR_WINNER 503
#define GVAR_FLAG_PLAYER 504
#define GVAR_FLAG_STATUS 510
//________________________________Game phases_______________________
#define GPHASE_BEGIN 1//objects are restarting
#define GPHASE_WAIT_PLAYERS 2 //wait plaiers if needed and respawn for start
#define GPHASE_START_GAME 3 //fade on and spawn
#define GPHASE_GAME 4 //game
//#define GPHASE_FLAG_IN_BASE 4
//#define GPHASE_FLAG_ON_GROUND 5
//#define GPHASE_FLAG_ON_PLAYER 6
#define GPHASE_MISSION_COMPLETED 7
//________________________________Recover___________________________
#define RECOVER_TIME 5.0f // time to recover player after killed
#define NORECOV_TIME 3.0f // disable time of recoverplace after recovering someone there
#define REC_WPNAME "HTF_%d"
#define REC_MAX 64
BOOL SRV_CheckEndRule(float time){
int frags;
dword win_pl;
BOOL completed=FALSE;
switch(gEndRule){
case SC_MP_ENDRULE_TIME:
if (gPlayersConnected>0) gTime += time;
SC_MP_EndRule_SetTimeLeft(gTime,gPlayersConnected>0);
if (gTime>gEndValue) completed=TRUE;
break;
case SC_MP_ENDRULE_FRAGS:
win_pl = SC_MP_GetMaxFragsPl(&frags);
if (win_pl){
if (frags>=gEndValue)completed=TRUE;
}
break;
case SC_MP_ENDRULE_POINTS:
win_pl = SC_MP_GetMaxPointsPl(&frags);
if (win_pl){
if (frags>=gEndValue)completed=TRUE;
case GPHASE_GAME:
flag_phase=SC_ggi(GVAR_FLAG_STATUS);
switch(flag_phase){
case FLAG_PH_INBASE: //_________
flag_pos = orig_flag_pos;
case FLAG_PH_ONGROUND: //_________
Flag_Player_id = SC_GetNearestPlayer(&flag_pos,&pl_dist);
if ((Flag_Player_id)&&(pl_dist<1.5f)){
Flag_Player_handle = SC_MP_GetHandleofPl(Flag_Player_id);
update_timer=0;
SC_sgi(GVAR_FLAG_PLAYER, Flag_Player_handle);
SC_SRV_Item_Release(Flag_Ground_ID);// release ground flag
SC_sgi(GVAR_FLAG_STATUS,FLAG_PH_ONPLAYER);
//gPhase=GPHASE_FLAG_ON_PLAYER;
//SC_sgi(GVAR_GPHASE,gPhase);
}else{// no players around
if (flag_phase==FLAG_PH_ONGROUND){
SC_Item_GetPos(Flag_Ground_ID,&flag_pos);// update flag pos because of dynamics
On_Ground_Timer-= info->elapsed_time;
if(On_Ground_Timer < 0 ){
SC_sgi(GVAR_FLAG_STATUS,FLAG_PH_INBASE);
//gPhase=GPHASE_FLAG_IN_BASE;
//SC_sgi(GVAR_GPHASE,gPhase);
}
}
}
break;
case FLAG_PH_ONPLAYER: //_________
update_timer+= info->elapsed_time;
if(update_timer>SECONDS_FOR_POINT){
SC_P_MP_AddPoints(Flag_Player_id,1);
update_timer=0;
}
if (!SC_P_IsReady(Flag_Player_id) || (Flag_Player_killed)){//exit game or dead
Flag_Player_killed = FALSE;
update_timer=0;
if (SC_Item_GetPos(Flag_Ground_ID,&flag_pos)){ // flag on ground
SC_sgi(GVAR_FLAG_STATUS,FLAG_PH_ONGROUND);
//gPhase=GPHASE_FLAG_ON_GROUND;
//SC_sgi(GVAR_GPHASE,gPhase);
}else {//no flag, add to base
SC_sgi(GVAR_FLAG_STATUS,FLAG_PH_INBASE);
//gPhase=GPHASE_FLAG_IN_BASE;
//SC_sgi(GVAR_GPHASE,gPhase);
}
}
break;
}
break;
case GPHASE_MISSION_COMPLETED:
break;
}
//________________________________________________________________
//gPlayersConnected = 64;
//SC_MP_EnumPlayers(enum_pl,&gPlayersConnected,SC_MP_ENUMPLAYER_SIDE_ALL);
if (SRV_CheckEndRule(info->elapsed_time)) break;
for (i=0;i<gRecs;i++)
gRecTimer[i] -= info->elapsed_time;
break;
case SC_NET_MES_CLIENT_TICK:
switch(SC_ggi(GVAR_GPHASE)){
case GPHASE_BEGIN: //___________________________CLN______BEGIN
break;
case GPHASE_WAIT_PLAYERS: //___________________________CLN______WAIT_PLAYERS
SC_NOD_SetTransform(dir_obj_id,&trans_hide); //hide dir object
witxt = SC_Wtxt(1076);//1076
SC_GetScreenRes(&sc_width,&sc_height);
val= sc_width - SC_Fnt_GetWidthW(witxt,1);
SC_Fnt_WriteW(val * 0.5f,15,witxt,1,0xffffffff);
break;
case GPHASE_START_GAME: //___________________________CLN______START_GAME
if (fade_off){
client_fade_timer -= info->elapsed_time;
if (client_fade_timer < (FADE_TIME + 0.1f)){
SC_FadeTo(TRUE, FADE_TIME);
fade_off=FALSE;
client_fade_timer=RESTART_TIMER;
fade_off_timer=0;
//reset objexts and states
SC_NOD_SetTransform(dir_obj_id,&trans_hide); //hide dir object
show_flag_pos_timer=0.0;
}
}
swprintf(wtxt,SC_AnsiToUni("%s %S", wtxt2),SC_Wtxt(6030)," - HTF (Hold The Flag)");
val= (sc_width*0.5) - (SC_Fnt_GetWidthW(wtxt,1)*0.5);
SC_Fnt_WriteW(val,15,wtxt,1,0xffffffff);
break;
case GPHASE_GAME:
//FADE OFF
if (!fade_off){
fade_off_timer += info->elapsed_time;
if (fade_off_timer > 0.2f){// looks better so because spawn is with short delay
SC_FadeTo(FALSE, FADE_TIME);
fade_off=TRUE;
}
}
switch(SC_ggi(GVAR_FLAG_STATUS)){
case FLAG_PH_INBASE: //_________
if(!cln_flag_in_base){
SC_NOD_SetTransform(dir_obj_id,&trans_hide); //hide dir object
show_flag_pos_timer=0.0;
icon[0].color = 0xffffffff;
icon[0].type = SC_HUD_MP_ICON_TYPE_NONE;
icon[0].icon_id = 3;
SC_MP_SetIconHUD(icon,1);
SC_DUMMY_Set_DoNotRenHier2(gFlagNod,FALSE);//show base flag
//SC_NOD_GetWorldPos(gFlagNod, &vec);
//SC_HUD_RadarShowPos(&vec, 0xff000000);//0xffffffff// white
swprintf(wtxt,SC_AnsiToUni("%s",wtxt2),SC_Wtxt(1069));//#1069: #tee Flag returned!
SC_GameInfoW(wtxt);
last_flag_player=-1;
cln_flag_in_base=TRUE;
cln_flag_on_ground=FALSE;
}
break;
case FLAG_PH_ONGROUND: //_________
if(!cln_flag_on_ground){
SC_NOD_SetTransform(dir_obj_id,&trans_hide); //hide dir object
show_flag_pos_timer=0.0;
icon[0].color = 0xffffffff;
icon[0].type = SC_HUD_MP_ICON_TYPE_NONE;
icon[0].icon_id = 5;
SC_MP_SetIconHUD(icon,1);
SC_DUMMY_Set_DoNotRenHier2(gFlagNod,TRUE);// dont show base flag
cln_Flag_Player_handle = SC_ggi(GVAR_FLAG_PLAYER);
last_flag_player=-1;
if(cln_Flag_Player_handle){
pl_id = SC_MP_GetPlofHandle(cln_Flag_Player_handle);
SC_P_UnLink3pvEqp(pl_id,0);
swprintf(wtxt,SC_AnsiToUni("%s - %S",wtxt2),SC_Wtxt(1068),SC_P_GetName(pl_id));//#1068: #tee Flag dropped!
SC_GameInfoW(wtxt);
}
cln_flag_on_ground=TRUE;
cln_flag_in_base=FALSE;
}
break;
case FLAG_PH_ONPLAYER: //_________
cln_Flag_Player_handle = SC_ggi(GVAR_FLAG_PLAYER);
pl_id = SC_MP_GetPlofHandle(cln_Flag_Player_handle);
if(last_flag_player != cln_Flag_Player_handle){//flag on new player
SC_NOD_SetTransform(dir_obj_id,&trans_hide);
show_flag_pos_timer=0.0;
// preload flag eqp items
SC_PreloadBES(PRELOADBES_FLAG_VC,"G\\WEAPONS\\Vvh_flag\\Vvh_flag_VC_3pv.BES");
nod = SC_NOD_Get(NULL,"HTF_flag");
if (!nod) SC_message("'HTF_flag' not found 01");
gFlagNod = SC_NOD_Get(nod,"Vlajka VC");
if (!gFlagNod) SC_message("'HTF_flag' not found 02");
SC_NOD_GetWorldPos(nod,&orig_flag_pos);
if (info->param1){
// it's server
//_______________________________________________________________________________________
SC_sgi(GVAR_SERVER,1);
SC_MP_Gvar_SetSynchro(GVAR_GPHASE);
SC_MP_Gvar_SetSynchro(GVAR_GPHASE_TIME);
//SC_MP_Gvar_SetSynchro(GVAR_CUR_WEAP);
SC_MP_Gvar_SetSynchro(GVAR_WINNER);
SC_MP_Gvar_SetSynchro(GVAR_FLAG_PLAYER);
//SC_MP_Gvar_SetSynchro(GVAR_FLAG_TIMER);
for (i=300;i<364;i++){ //custom global variables for player id's
SC_MP_Gvar_SetSynchro(i);
}
//_______________________________________________________________________________________
for (i=400;i<464;i++){ //for player points
SC_MP_Gvar_SetSynchro(i);
}
//_______________________________________________________________________________________
SC_MP_GetSRVsettings(&SRVset);
SC_MP_SRV_InitWeaponsRecovery((float)SRVset.dm_weap_resp_time);
gRecs = 0;
for (i=0;i<REC_MAX;i++){
sprintf(txt,REC_WPNAME,i);
if (SC_NET_FillRecover(&gRec[gRecs],txt)) gRecs++;
}
#if _GE_VERSION_ >= 170
i = REC_MAX - gRecs;
SC_MP_GetRecovers(SC_MP_RESPAWN_HTF,&gRec[gRecs],&i);
gRecs += i;
#endif
if (gRecs==0){
SC_message("no 'HTF' recover place added! Will use 'DM' recover place if exist.");
i = REC_MAX - gRecs;
SC_MP_GetRecovers(SC_MP_RESPAWN_DM,&gRec[gRecs],&i);
gRecs += i;
}
CLEAR(gRecTimer);
}// if (info->param1)
}//if (info->param2)
break;// SC_NET_MES_LEVELINIT
case SC_NET_MES_RENDERHUD:
if(SC_KeyPressed(0x0F)){//TAB pressed
if(SHOW_PLAYER_COLOR){
SC_MP_HUD_SelectPl(SC_PC_Get(),0x1100ffff);
}
if (SHOW_PLAYERS_COUNT){
SC_MP_EnumPlayers(enum_pl,&j,SC_MP_ENUMPLAYER_SIDE_ALL);
if (j==1) player_s = SC_Wtxt(350); else player_s = SC_Wtxt(7001);
swprintf(wtxt,SC_AnsiToUni("%d %s", wtxt2),j,player_s);
SC_Fnt_WriteW(100,25,wtxt,1,0xffffffff);
}
}else if(SC_ggi(GVAR_GPHASE)==GPHASE_MISSION_COMPLETED){
if (SC_MP_GetMaxPointsPl(&max_point)){
if(max_point > 0){
SC_MP_HUD_SelectPl(SC_MP_GetMaxPointsPl(&max_point),0x88440000);
}
}
}
break;
case SC_NET_MES_SERVER_RECOVER_TIME:
if (info->param2){
info->fval1 = 0.1f;
}
else{// killed
details compared with original DM:
- added automatic global variable system
Script:
Spoiler:[ShowHide]
Code
// VIETCONG 1
// DM script - compatible with synchronized objects
// modified by Ando
// v2.0
// NOTES:
// 1.0 modyfied for global vriables
// 1.2 - added variable for server (600) to detect server from object scripts
// 1.2 - new G-var system (object scripts counting g-vars to channel 601 )
// 1.3 - added game phase for object scripts resets
// 2.0 - successfully tested with L|DC-78
#define RECOVER_TIME 5.0f // time to recover player after killed
#define NORECOV_TIME 3.0f // disable time of recoverplace after recovering someone there
#define REC_WPNAME "DM%d"
#define REC_MAX 64
//________________________________
//global variable system for object synchro
#define GVAR_SERVER 600 // server ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT 601 // count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start 602 //start Global variable
//________________________________
#define GVAR_GPHASE 500 // important to use game phase and channel 500 for synchronised objects
//________________________________
DM script with automatic global variable system (advanced)
details compared with original DM:
- added automatic global variable system
- restart with fade
- show player in fifferent color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
Script:
Spoiler:[ShowHide]
Code
// VIETCONG 1
// DM script (with automatic global variables for synchronized objects)
// modified by Ando
// v3.1
// NOTES:
// 1.0 - modyfied for global vriables
// 1.2 - added variable for server (600) to detect server from object scripts
// 1.2 - new G-var system (object scripts counting g-vars to channel 601 )
// 1.3 - added game phase for object scripts resets
// 2.0 - successfully tested with L|DC-78
// 3.0 - added fade for restart
// 3.1 - show player in fifferent color (on/off option in script)
// 3.1 - show players count when "TAB" is pressed (on/off option in script)
#define FADE_TIME 0.8
//________________________________
//global variable system for object synchro
#define GVAR_SERVER 600 // server ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT 601 // count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start 602 //start Global variable
//________________________________
#define GVAR_GPHASE 500 // important to use game phase and channel 500 for synchronised objects
//________________________________
#define RECOVER_TIME 5.0f // time to recover player after killed
#define NORECOV_TIME 3.0f // disable time of recoverplace after recovering someone there
#define REC_WPNAME "DM%d"
#define REC_MAX 64
BOOL SRV_CheckEndRule(float time){
int frags;
switch(gEndRule){
case SC_MP_ENDRULE_TIME:
if (gPlayersConnected>0) gTime += time;
SC_MP_EndRule_SetTimeLeft(gTime,gPlayersConnected>0);
if (gTime>gEndValue){
SC_MP_LoadNextMap();
return TRUE;
}
break;
case SC_MP_ENDRULE_FRAGS:
if (SC_MP_GetMaxFragsPl(&frags)){
if (frags>=gEndValue){
SC_MP_LoadNextMap();
return TRUE;
}
}
break;
default:
SC_message("EndRule unsopported: %d",gEndRule);
break;
}// switch(gEndRule)
return FALSE;
}// void SRV_CheckEndRule(float time)
int ScriptMain(s_SC_NET_info *info){
char txt[128],*itxt;
ushort wtxt[128],wtxt2[64],*witxt;
dword i,j;
s_SC_MP_Recover *precov;
s_SC_MP_hud hudinfo;
s_SC_MP_EnumPlayers enum_pl[64];
s_SC_MP_SRV_settings SRVset;
switch(info->message){
case SC_NET_MES_SERVER_TICK:
//________________________________________________________________
gPhase_timer -= info->elapsed_time;
switch(gPhase){
case GPHASE_BEGIN:
if (gPhase_timer <= 0.0f){
gPhase = GPHASE_GAME;
SC_sgi(GVAR_GPHASE,gPhase);//(1 = begin) For sync. objects. server restart_________________________________________
}
break;// GPHASE_BEGIN
case GPHASE_GAME:
break;
case GPHASE_BEFORE_RESTART:
if (gPhase_timer<0.0f){ //wait before restart
gPhase = GPHASE_RESTARTING;
SC_sgi(GVAR_GPHASE,gPhase);//(1 = begin) For sync. objects. server restart
}
break;
case GPHASE_RESTARTING:
gTime = 0;
gPhase=GPHASE_BEGIN;
gPhase_timer = 3.0f;
SC_sgi(GVAR_GPHASE,gPhase);//(1 = begin) For sync. objects. server restart
SC_MP_SRV_ClearPlsStats();
SC_MP_SRV_InitGameAfterInactive();
SC_MP_RecoverAllNoAiPlayers();
break;
}
//________________________________________________________________
gPlayersConnected = 64;
SC_MP_EnumPlayers(enum_pl,&gPlayersConnected,SC_MP_ENUMPLAYER_SIDE_ALL);
if (SRV_CheckEndRule(info->elapsed_time)) break;
for (i=0;i<gRecs;i++)
gRecTimer[i] -= info->elapsed_time;
break;
case SC_NET_MES_CLIENT_TICK:
switch(SC_ggi(GVAR_GPHASE)){
case GPHASE_BEGIN:
if (!fade_off){
fade_off_timer += info->elapsed_time;
if (fade_off_timer > 0.2f){// looks better so because spawn is with short delay
SC_FadeTo(FALSE, FADE_TIME);
fade_off=TRUE;
}
}
break;
case GPHASE_BEFORE_RESTART:
if (fade_off){
client_fade_timer -= info->elapsed_time;
if (client_fade_timer < (FADE_TIME + 0.1f)){
SC_FadeTo(TRUE, FADE_TIME);
fade_off=FALSE;
client_fade_timer=RESTART_TIMER;
fade_off_timer=0;
}
}
break;
case GPHASE_RESTARTING:
break;
}// switch(gPhase)
//_____________________________
break;// SC_NET_MES_CLIENT_TICK
case SC_NET_MES_LEVELPREINIT:
client_fade_timer=RESTART_TIMER;
SC_sgi(GVAR_MP_MISSIONTYPE,GVAR_MP_MISSIONTYPE_DM);
gEndRule = info->param1;
gEndValue = info->param2;
gTime = 0.0f;
SC_MP_EnableBotsFromScene(FALSE);
break;// SC_NET_MES_LEVELPREINIT
case SC_NET_MES_LEVELINIT:
//_____________________________________automatic custom global variables_________________
for (i=GVAR_USE_start;i<GVAR_USE_start+SC_ggi(GVAR_COUNT)+1;i++){ //custom global variables
SC_MP_Gvar_SetSynchro(i);
}
//_______________________________________________________________________________________
SC_MP_GetSRVsettings(&SRVset);
SC_MP_SRV_InitWeaponsRecovery((float)SRVset.dm_weap_resp_time);
gRecs = 0;
for (i=0;i<REC_MAX;i++){
sprintf(txt,REC_WPNAME,i);
if (SC_NET_FillRecover(&gRec[gRecs],txt)) gRecs++;
}
#if _GE_VERSION_ >= 133
i = REC_MAX - gRecs;
SC_MP_GetRecovers(SC_MP_RESPAWN_DM,&gRec[gRecs],&i);
gRecs += i;
#endif
SC_Log(3,"DM respawns: %d",gRecs);
if (gRecs==0) SC_message("no recover place defined!");
CLEAR(gRecTimer);
}// if (info->param1)
}//if (info->param2)
break;// SC_NET_MES_LEVELINIT
case SC_NET_MES_RENDERHUD:
// EXTRA TAB INFO
if(SC_KeyPressed(0x0F)){//TAB pressed
if(SHOW_PLAYER_COLOR){
SC_MP_HUD_SelectPl(SC_PC_Get(),0x1100ffff);
}
if (SHOW_PLAYERS_COUNT){
SC_MP_EnumPlayers(enum_pl,&j,SC_MP_ENUMPLAYER_SIDE_ALL);
if (j==1) player_s = SC_Wtxt(350); else player_s = SC_Wtxt(7001);
swprintf(wtxt,SC_AnsiToUni("%d %s", wtxt2),j,player_s);
SC_Fnt_WriteW(100,25,wtxt,1,0xffffffff);
}
}
// end of extra tab info
break;
case SC_NET_MES_SERVER_RECOVER_TIME:
if (info->param2){
info->fval1 = 0.1f;
}
else{// killed
info->fval1 = RECOVER_TIME;
}
break;
case SC_NET_MES_SERVER_RECOVER_PLACE:
precov = (s_SC_MP_Recover*)info->param2;
i = SC_MP_SRV_GetBestDMrecov(gRec,gRecs,gRecTimer,NORECOV_TIME);
gRecTimer[i] = NORECOV_TIME;
*precov = gRec[i];
break;
case SC_NET_MES_RESTARTMAP:
//___________________________________________________________
gPhase_timer = RESTART_TIMER;
gPhase = GPHASE_BEFORE_RESTART;
SC_sgi(GVAR_GPHASE,gPhase);
TDM script with automatic global variable system (simple)
details compared with original TDM:
- added automatic global variable system
Script:
Spoiler:[ShowHide]
Code
// VIETCONG 1
// TDM script - compatible with synchronized objects
// modified by Ando
// v2.0
// NOTES:
// 1.0 modyfied for global vriables
// 1.2 - added variable for server (600) to detect server from object scripts
// 1.2 - new G-var system (object scripts counting g-vars to channel 601 )
// 1.3 - added game phase for object scripts resets
// 2.0 - successfully tested with L|DC-78
#define RECOVER_TIME 5.0f // time to recover player after killed
#define NORECOV_TIME 3.0f // disable time of recoverplace after recovering someone there
#define REC_WPNAME "DM%d"
#define REC_MAX 64
//________________________________
//global variable system for object synchro
#define GVAR_SERVER 600 // server ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT 601 // count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start 602 //start Global variable
//________________________________
#define GVAR_GPHASE 500 // important to use game phase and channel 500 for synchronised objects
//________________________________
case SC_NET_MES_SERVER_TICK:
//________________________________________________________________
if (gPhase==1){
gPhase_timer -= info->elapsed_time;
if (gPhase_timer <= 0.0f){
gPhase=2;
SC_sgi(GVAR_GPHASE,gPhase);//(1 = begin) For sync. objects. server restart_________________________________________
}
}
//________________________________________________________________
if (SRV_CheckEndRule(info->elapsed_time)) break;
for (i=0;i<gRecs;i++)
gRecTimer[i] -= info->elapsed_time;
j = 64;
if (SC_MP_EnumPlayers(enum_pl,&j,SC_MP_ENUMPLAYER_SIDE_ALL)){
if ((j==0)&&((gSideFrags[0]+gSideFrags[1])!=0)){
gSideFrags[0] = 0;
gSideFrags[1] = 0;
UpdateSideFrags();
}// if ((side[0]+side[1])==0)
}// if (SC_MP_EnumPlayers(enum_pl,&j,SC_MP_ENUMPLAYER_SIDE_ALL))
gPlayersConnected = j;
break;
case SC_NET_MES_CLIENT_TICK:
case SC_NET_MES_LEVELINIT:
//_____________________________________automatic custom global variables_________________
for (i=GVAR_USE_start;i<GVAR_USE_start+SC_ggi(GVAR_COUNT)+1;i++){ //custom global variables
SC_MP_Gvar_SetSynchro(i);
}
//_______________________________________________________________________________________
TDM script with automatic global variable system (advanced)
details compared with original TDM:
- added automatic global variable system
- restart with fade
- show player in fifferent color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
Script:
Spoiler:[ShowHide]
Code
// VIETCONG 1
// TDM script (with automatic global variables for synchronized objects)
// modified by Ando
// v3.1
// NOTES:
// 1.0 modyfied for global vriables
// 1.2 - added variable for server (600) to detect server from object scripts
// 1.2 - new G-var system (object scripts counting g-vars to channel 601 )
// 1.3 - added game phase for object scripts resets
// 2.0 - successfully tested with L|DC-78
// 3.0 - added fade for restart
// 3.1 - show player in fifferent color (on/off option in script)
// 3.1 - show players count when "TAB" is pressed (on/off option in script)
#define FADE_TIME 0.8
//________________________________
//global variable system for object synchro
#define GVAR_SERVER 600 // server ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT 601 // count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start 602 //start Global variable
//________________________________
#define GVAR_GPHASE 500 // important to use game phase and channel 500 for synchronised objects
//________________________________
#define RECOVER_TIME 5.0f // time to recover player after killed
#define NORECOV_TIME 3.0f // disable time of recoverplace after recovering someone there
#define REC_WPNAME "DM%d"
#define REC_MAX 64
SC_MP_EnableBotsFromScene(FALSE);
break;// SC_NET_MES_LEVELPREINIT
case SC_NET_MES_LEVELINIT:
//_____________________________________automatic custom global variables_________________
for (i=GVAR_USE_start;i<GVAR_USE_start+SC_ggi(GVAR_COUNT)+1;i++){ //custom global variables
SC_MP_Gvar_SetSynchro(i);
}
//_______________________________________________________________________________________
//___PLAYER IN/OUT SYNCHRO_____________
player = SC_PC_Get();
//test // still crach when player is dead
/*
if (!SC_P_IsReady(player)) {
susp = SC_NOD_Get(info->master_nod,"pasentry");
SC_NOD_GetWorldPos(susp,&car_vec);
SC_P_ExitHeli(player,&car_vec);
//SC_message("player dead");
return TRUE;
}*/
if (player){
PC_car_id = SC_P_IsInCarEx(player, &PC_entry);
if (PC_car_id){// PC is on car
if (PC_car_id == car){ // PC is in current car
if (PC_in_cur_car > -1){// was already in
}else{// just entered
PC_in_cur_car=PC_entry;
if ( SC_ggi(my_gvar_seat_[PC_entry])!= SC_MP_GetHandleofPl(player)){// update only when needed
SC_sgi(my_gvar_seat_[PC_entry],SC_MP_GetHandleofPl(player));
//SC_P_SetSelWeapon(player, 1);
}
}
if(check_timer>0.5){
if( PC_entry == 0){//PC is driver
//Send car pos
Send_car_pos(info);
*/
driver_timer=0;
}
}
}
}else{// PC isnt in car
if (PC_in_cur_car == 0 ){// was using driver seat
if ( pl_in_car[0]== 0){//nobady in driver seat
driver_timer+=info->time;
if (driver_timer < 4){// update car pos 4 sec after triver left it and no other driver
if(check_timer>0.5){
Send_car_pos(info);
}
}else{
SC_sgi(my_gvar_seat_[PC_in_cur_car],0);// removed from Gvar
PC_in_cur_car=-1;//
}
}
}
else if( PC_in_cur_car >= 0 ){ //____is PC left from car
if ( SC_ggi(my_gvar_seat_[PC_in_cur_car])== SC_MP_GetHandleofPl(player)){// was PC there?
SC_sgi(my_gvar_seat_[PC_in_cur_car],0);// removed from Gvar
PC_in_cur_car=-1;//
}
}
}
}
//SC_Osi("S1: %d s2: %d s3: %d", SC_ggi(my_gvar_seat_[0]),SC_ggi(my_gvar_seat_[1]),SC_ggi(my_gvar_seat_[2]));
if(check_timer>0.5){
check_timer=0;
//______________________________CHECK ALL SEATS___________
for (j=0;j<MP_CAR_SEATS;j++) {
cur_pl_handle = SC_ggi(my_gvar_seat_[j]);
//______________________________EXIT PLAYER IF NEEDED__________
if (pl_in_car[j] > 0){//pl was in car
Cur_player = SC_MP_GetPlofHandle(pl_in_car[j]);
if(pl_in_car[j] != cur_pl_handle){// not in car and same slot anymore
sprintf(txt, "S_Entry_%d", j+1);
//susp = SC_NOD_Get(info->master_nod,txt);
susp = SC_NOD_Get(info->master_nod,"pasentry");
SC_NOD_GetWorldPos(susp,&car_vec);
SC_P_ExitHeli(Cur_player,&car_vec);
pl_in_car[j]=0;
if (SC_ggi(GVAR_SERVER) == 1){ // its server
if (j==0){// driver seat
SC_P_GetPos(Cur_player, &car_vec);
SC_P_Recover(Cur_player, &car_vec, SC_P_GetRot(Cur_player));
}
}
}
}
//_____________________________ADD PLAYER IF NEEDED____________
if (cur_pl_handle>0){
Cur_player = SC_MP_GetPlofHandle(cur_pl_handle);
Player_CAR = SC_P_IsInCarEx(Cur_player, &cur_entry);
if (Player_CAR == car){//player is already in current car
//___somebody drive(not pc), and need to get car pos+rot
if ((j==0) && ( Cur_player != player)){// player is driver AND not PC
//get new pos
Get_car_pos(info);
car_stil_move_timer=4;
//wheel
SC_NOD_GetTransform(wheel_id,&trans);
trans.rot.x = SC_ggf(my_gvar_steer_LR);
trans.rot.y = SC_ggf(my_gvar_steer_LR);
trans.rot.z = SC_ggf(my_gvar_steer_LR);
SC_NOD_SetTransform(wheel_id,&trans);
*/
}
}else if (Cur_player != player){ //need to add him
//SC_Osi("need to add him");
SC_P_SetToCar(Cur_player, CAR_name, j); // add to car
pl_in_car[j]=cur_pl_handle;//
}
}
}
//___OBJECT MOVEMENT AFTER SOMEBODY USED IT_____________
if (car_stil_move_timer > 0){// somebody was driving les than 4 sec ago
if (( pl_in_car[0]== 0) && (PC_in_cur_car != 0)){//nobady in driver seat && pc not and wasnt in car
SC_Osi("get car pos");
Get_car_pos(info);
}
}
}
Known bugs:
- player (client) will be kicked of from server with high speed (Cheat #2)
- was more bugs but I dont remember now.
I think Brchi made fix for it, special vcded.exe where is modified speedcheck (VCGUARD?). This fix is used serverside only so clients don't need to have it.