Raised This Month: $51 Target: $400
 12% 

[CS:GO] VIP Mode - GO:VIP


Post New Thread Reply   
 
Thread Tools Display Modes
veli
Senior Member
Join Date: Apr 2012
Location: Netherlands
Old 07-18-2014 , 13:12   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #31

Can u add a model option too? So the vip get a special model so people can know he is the vip. Would be great if possible.
veli is offline
Koga73
Senior Member
Join Date: Mar 2011
Location: 🍩
Old 01-26-2015 , 20:20   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #32

Quote:
Originally Posted by veli View Post
Can u add a model option too? So the vip get a special model so people can know he is the vip. Would be great if possible.
+1
__________________
Koga73 is offline
viksando
New Member
Join Date: Feb 2011
Old 10-28-2016 , 17:50   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #33

[CS:Source] All-fixed, functioning plugin with money rewards, scoring, custom VIP model and added cvars.

CVARS added by me:

govip_health - Base health for the VIP player, default is 200 (more like in the original mode in CS 1.6 and earlier)
govip_reward - Default is 2500 - working money reward for escaping as the VIP, or eliminating the VIP as a terrorist. Given at the start of the next round.

*NOTE - the same amount of money as the money_reward cvar states will be taken from the whole team if:

1. The VIP is killed by the Terrorists (Default: CT Team -$2500, T Team +$2500)
2. The VIP escapes to the rescue zone (Default: T Team -$2500, CT Team +$2500)

I'm publishing this as official for CS:Source, since the custom model is using a CSS skin and I play with this plugin on my CSS server.
You can easily port the code for CS:GO by adding a CS:GO custom skin to it. (edit the PrecacheModel, SetEntityModel and AddFileToDownloadsTable lines in the code to suit your custom model)

WARNING! Sorry for misleading you guys about the porting to CS:GO. It would appear that some of the EVENT types in CSGO differ from the ones in CSS. If you wanna port it to CSGO, you'd have to take a look at the scoring system and change some of the parameters to the way they are in CSGO.

Here's the code:

PHP Code:
/**
 * 00. Includes
 * 01. Globals
 * 02. Forwards
 * 03. Events
 * 04. Functions
 */
 
// 00. Includes     
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdktools_functions>
#include <sdkhooks>
#include <clients>

// 01. Globals
#define GOVIP_MAINLOOP_INTERVAL 0.1
#define GOVIP_MAXPLAYERS 64

enum VIPState {
    
VIPState_WaitingForMinimumPlayers 0,
    
VIPState_Playing
};

new 
CurrentVIP 0;
new 
LastVIP 0;
new 
VIPState:CurrentState VIPState_WaitingForMinimumPlayers;
new 
Handle:CVarMinCT INVALID_HANDLE;
new 
Handle:CVarMinT INVALID_HANDLE;
new 
Handle:CVarVIPWeapon INVALID_HANDLE;
new 
Handle:CVarVIPhp INVALID_HANDLE;
new 
Handle:CVarVIPreward INVALID_HANDLE;
new 
MyWeaponsOffset 0;
new 
Handle:RescueZones INVALID_HANDLE;
new 
bool:RoundComplete false;
new 
winner 0;

// 02. Forwards
public OnPluginStart() {
    
CVarMinCT CreateConVar("govip_min_ct""2""Minimum number of CTs to play GOVIP");
    
CVarMinT CreateConVar("govip_min_t""1""Minimum number of Ts to play GOVIP");
    
CVarVIPWeapon CreateConVar("govip_weapon""weapon_p250""Weapon given to VIP");
    
CVarVIPhp CreateConVar("govip_health""200""VIP Base Health")
    
CVarVIPreward CreateConVar("govip_reward""2500""Money reward for winning by Escaping(CT) or killing the VIP(T)")
    
    
CurrentState VIPState_WaitingForMinimumPlayers;
    
    
CreateTimer(GOVIP_MAINLOOP_INTERVALGOVIP_MainLoopINVALID_HANDLETIMER_REPEAT);

    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeath);
    
    
MyWeaponsOffset FindSendPropInfo("CBaseCombatCharacter""m_hMyWeapons");
    
    
RescueZones CreateArray();
    
    
RoundComplete false;
}

public 
OnClientPutInServer(client) {
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
    return;
}

public 
OnClientDisconnect(client) {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP || RoundComplete) {
        return;
    }
    
    
RoundComplete true;
    
    
LastVIP CurrentVIP;
    
    
CurrentVIP 0;
    
    
PrintToChatAll("%s""[GO:VIP] The VIP has left, round ends in a draw.");
    
    
CS_TerminateRound(3.0CSRoundEnd_Draw);
    
winner 0;

}

public 
OnMapStart() {
    new 
String:buffer[512];
    
    
PrecacheModel("models/player/vip/stryker.mdl"true);
    
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eye.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_l.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_l.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_r.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_r.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Diff.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Diff.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Norm.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Spec.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_ao.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Diff.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Diff.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Norm.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Spec.vtf");
    
    
AddFileToDownloadsTable("models/player/vip/stryker.dx80.vtx");
    
AddFileToDownloadsTable("models/player/vip/stryker.dx90.vtx");
    
AddFileToDownloadsTable("models/player/vip/stryker.mdl");
    
AddFileToDownloadsTable("models/player/vip/stryker.phy");
    
AddFileToDownloadsTable("models/player/vip/stryker.sw.vtx");
    
AddFileToDownloadsTable("models/player/vip/stryker.vvd");
    
    new 
trigger = -1;
    while((
trigger FindEntityByClassname(trigger"trigger_multiple")) != -1) {
        
GetEntPropString(triggerProp_Data"m_iName"buffersizeof(buffer));
        if(
StrContains(buffer"vip_rescue_zone"false) == 0) {
            
SDKHook(triggerSDKHook_TouchTouchRescueZone);
        }
    }
    
    
ClearArray(RescueZones);
    
    
GetCurrentMap(buffersizeof(buffer));
    
    new 
Handle:kv CreateKeyValues("RescueZones");
    
    new 
String:path[1024];
    
BuildPath(Path_SMpathsizeof(path), "configs/rescue_zones.cfg");
    
    
FileToKeyValues(kvpath);
    
    if(
KvJumpToKey(kvbuffer)) {
        
KvGotoFirstSubKey(kv);
        
        do {
            new 
Float:radius KvGetFloat(kv"radius"200.0);
        
            
KvGetString(kv"coords"buffersizeof(buffer));
            new 
String:coords[3][128];
            
ExplodeString(buffer" "coords3128);

            
PrintToServer("[GO:VIP] Loading rescue zone at [%s, %s, %s] with radius of %f units."coords[0], coords[1], coords[2], radius);
                        
            new 
Handle:rescueZone CreateArray();
            
PushArrayCell(rescueZoneradius);
            
PushArrayCell(rescueZoneStringToFloat(coords[0]));
            
PushArrayCell(rescueZoneStringToFloat(coords[1]));
            
PushArrayCell(rescueZoneStringToFloat(coords[2]));
            
            
PushArrayCell(RescueZonesrescueZone);
        } while (
KvGotoNextKey(kv));
    }    
    
    
CloseHandle(kv);
}

// 03. Events
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) {
    
RoundComplete false;
    
CurrentVIP GetRandomPlayerOnTeam(CS_TEAM_CTLastVIP);
    new 
playercashoffs FindSendPropInfo("CCSPlayer""m_iAccount");
    
    if(
CurrentState != VIPState_Playing) {
        return 
Plugin_Continue;
    }
    
    for (new 
1<= MaxClientsi++) {
        
        if (
IsClientInGame(i) && IsPlayerAlive(i)) {
            new 
pl_team GetClientTeam(i);
            new 
iWeapon GetPlayerWeaponSlot(i4);
            new 
playercash GetEntData(iplayercashoffs);
            if (
iWeapon != -&& IsValidEdict(iWeapon)) {
                
decl String:szClassName[64];
                
GetEdictClassname(iWeaponszClassNamesizeof(szClassName));
                if (
StrEqual(szClassName"weapon_c4"false)) {
                    
RemovePlayerItem(iiWeapon);
                    
RemoveEdict(iWeapon);
                }
            }
            if (
winner == && pl_team == 2) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                
SetEntData(iplayercashoffscashreward);    
            }
            if (
winner == 22 && pl_team == 2) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                if (
playercash >= GetConVarInt(CVarVIPreward))
                {
                    
SetEntData(iplayercashoffscashreward);
                }
                else
                {
                    
SetEntData(iplayercashoffs0);
                }
            }
            if (
winner == 22 && pl_team == 3) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                
SetEntData(iplayercashoffscashreward);    
            }
            if (
winner == && pl_team == 3) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                if (
playercash >= GetConVarInt(CVarVIPreward))
                {
                    
SetEntData(iplayercashoffscashreward);
                }
                else
                {
                    
SetEntData(iplayercashoffs0);
                }
            }
        }
    }
        
    
RemoveMapObj();
        
    if(
CurrentVIP == || !IsValidPlayer(CurrentVIP)) {
        return 
Plugin_Continue;
    }
    
    new 
String:VIPName[128];
    
GetClientName(CurrentVIPVIPNamesizeof(VIPName));
    
    
PrintToChatAll("[GO:VIP] \"%s\" is the VIP, CTs protect the VIP from the Terrorists!"VIPName);
    
    new 
String:VIPWeapon[256];
    new 
basehp GetConVarInt(CVarVIPhp);
    
GetConVarString(CVarVIPWeaponVIPWeaponsizeof(VIPWeapon));
    new 
ArmorOffs FindSendPropInfo("CCSPlayer""m_ArmorValue");
    
    new 
index CreateEntityByName(VIPWeapon);
    
    
    if(
index != -1) {
        
StripWeapons(CurrentVIP);
        
SetEntityModel(CurrentVIP"models/player/vip/stryker.mdl");
        
GivePlayerItem(CurrentVIPVIPWeapon);
        
SetEntityHealth(CurrentVIPbasehp);
        
SetEntData(CurrentVIPArmorOffs125);    
    }    

    
    return 
Plugin_Continue;
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
    if(
CurrentState != VIPState_Playing) {
        return 
Plugin_Continue;
    }
    
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    
    if(
client != CurrentVIP || RoundComplete) {
        return 
Plugin_Continue;
    }
    
    
RoundComplete true;
    
winner 1;
    
    
CS_TerminateRound(3.0CSRoundEnd_TerroristWin);
    
    
PrintToChatAll("%s""[GO:VIP] The VIP has died, Terrorists win!");
    
    
LastVIP CurrentVIP;
    
    
CurrentVIP 0;
    
    return 
Plugin_Continue;
}

// 04. Functions
public Action:GOVIP_MainLoop(Handle:timer) {
    new 
CTCount GetTeamClientCount(CS_TEAM_CT);
    new 
TCount GetTeamClientCount(CS_TEAM_T);
    
    if(
CurrentState == VIPState_WaitingForMinimumPlayers) {
        if(
CTCount >= GetConVarInt(CVarMinCT) && TCount >= GetConVarInt(CVarMinT)) {
            
CurrentState VIPState_Playing;
            
PrintToChatAll("%s""[GO:VIP] Starting the game!");
            return 
Plugin_Continue;
        }
    }
    else if(
CurrentState == VIPState_Playing) {
        if(
TCount GetConVarInt(CVarMinT) || CTCount GetConVarInt(CVarMinCT)) {
            
CurrentState VIPState_WaitingForMinimumPlayers;
            
PrintToChatAll("%s""[GO:VIP] Game paused, waiting for more players.");
            return 
Plugin_Continue;
        }
        
        if(
CurrentVIP == && RoundComplete == false) {
            
RoundComplete true;
                
            
CurrentVIP GetRandomPlayerOnTeam(CS_TEAM_CTLastVIP);
            
winner 0;
            
            
CS_TerminateRound(3.0CSRoundEnd_GameStart); 
        }
        else if(!
RoundComplete && IsValidPlayer(CurrentVIP)) {
            new 
Float:vipOrigin[3];
            
GetClientAbsOrigin(CurrentVIPvipOrigin);
            
            new 
rescueZoneCount GetArraySize(RescueZones);
            
            for(new 
rescueZoneIndex 0rescueZoneIndex rescueZoneCountrescueZoneIndex++) {
                new 
Handle:rescueZone GetArrayCell(RescueZonesrescueZoneIndex);
                
                new 
Float:rescueZoneOrigin[3];
                
rescueZoneOrigin[0] = GetArrayCell(rescueZone1);
                
rescueZoneOrigin[1] = GetArrayCell(rescueZone2);
                
rescueZoneOrigin[2] = GetArrayCell(rescueZone3);
                
                new 
Float:rescueZoneRadius GetArrayCell(rescueZone0);
                
                if(
GetVectorDistance(rescueZoneOriginvipOrigin) <= rescueZoneRadius) {
                    
RoundComplete true;
                    
                    
LastVIP CurrentVIP;
                    
                    
winner 22;
                    
CS_TerminateRound(3.0CSRoundEnd_CTWin);
                    
                    
PrintToChatAll("%s""[GO:VIP] The VIP has been rescued, Counter-Terrorists win.");
                    
                    break;
                }
            }
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action:OnWeaponCanUse(clientweapon) {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP) {
        return 
Plugin_Continue;
    }
    
    new 
String:entityClassName[256];
    
    
GetEntityClassname(weaponentityClassNamesizeof(entityClassName));
    
    new 
String:VIPWeapon[256];
    
GetConVarString(CVarVIPWeaponVIPWeaponsizeof(VIPWeapon));
     
    if(
StrEqual(entityClassName"weapon_knife"false) || StrEqual(entityClassNameVIPWeaponfalse)) {
        return 
Plugin_Continue;
    }
    
    return 
Plugin_Handled;
}

public 
Action:Command_JoinTeam(client, const String:command[], argc)  {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP) {
        return 
Plugin_Continue;
    }
    
    
PrintToChat(client"%s""[GO:VIP] You are not allowed to change teams while you are the VIP.");
    return 
Plugin_Handled;
}

bool:IsValidPlayer(client) {
    if(!
IsValidEntity(client) || !IsClientConnected(client) || !IsClientInGame(client)) {
        return 
false;
    }
    
    return 
true;
}

GetRandomPlayerOnTeam(teamignore 0) {
    new 
teamClientCount GetTeamClientCount(team);
    
    if(
teamClientCount <= 0) {
        return 
0;
    }
    
    new 
client;
    
    do {
        
client GetRandomInt(1MaxClients);
    } while((
teamClientCount && client == ignore) || !IsClientInGame(client) || GetClientTeam(client) != team);
    
    return 
client;
}

stock RemoveMapObj() {
    
decl maxent,i;
    
decl String:Class[65];
    
maxent GetMaxEntities();
    for (
i=0;i<=maxent;i++)
    {
        if(
IsValidEdict(i) && IsValidEntity(i))
        {
            
GetEdictClassname(i, Class, sizeof(Class));
            if(
StrContains("func_bomb_target_hostage_entity_func_hostage_rescue",Class) != -1)
            {
                
RemoveEdict(i);
            }
        }
    }
}


StripWeapons(client) {
    new 
weaponID;

    for(new 
020= (4)) {
        
weaponID GetEntDataEnt2(clientMyWeaponsOffset x);
        
        if(
weaponID <= 0) {
            continue;
        }
        
        new 
String:weaponClassName[128];
        
GetEntityClassname(weaponIDweaponClassNamesizeof(weaponClassName));
        
        if(
StrEqual(weaponClassName"weapon_knife"false)) {
            continue;
        }

        
RemovePlayerItem(clientweaponID);
        
RemoveEdict(weaponID);
    }
}

public 
TouchRescueZone(triggerclient) {

    
    if(!
IsValidPlayer(client)) {
        return;
    } 

    if(
CurrentState != VIPState_Playing || client != CurrentVIP || RoundComplete) {
        return;
    }
    
    
winner 22;
    
    
RoundComplete true;
    
    
CS_TerminateRound(3.0CSRoundEnd_CTWin);
    
    
LastVIP CurrentVIP;

    
CurrentVIP 0;
    
    
PrintToChatAll("[GO:VIP] The VIP has been rescued, Counter-Terrorists win.");


Last edited by viksando; 02-02-2018 at 11:55. Reason: PLUGIN COMPLETE!
viksando is offline
Azet
Member
Join Date: Oct 2013
Old 02-10-2017 , 07:46   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #34

Quote:
Originally Posted by viksando View Post
[CS:Source] All-fixed, functioning plugin with money rewards, scoring, custom VIP model and added cvars.

CVARS added by me:

govip_health - Base health for the VIP player, default is 200 (more like in the original mode in CS 1.6 and earlier)
govip_reward - Default is 2500 - working money reward for escaping as the VIP, or eliminating the VIP as a terrorist. Given at the start of the next round.

*NOTE - the same amount of money as the money_reward cvar states will be taken from the whole team if:

1. The VIP is killed by the Terrorists (Default: CT Team -$2500, T Team +$2500)
2. The VIP escapes to the rescue zone (Default: T Team -$2500, CT Team +$2500)

I'm publishing this as official for CS:Source, since the custom model is using a CSS skin and I play with this plugin on my CSS server.
You can easily port the code for CS:GO by adding a CS:GO custom skin to it. (edit the PrecacheModel, SetEntityModel and AddFileToDownloadsTable lines in the code to suit your custom model)

Here's the code:

PHP Code:
/**
 * 00. Includes
 * 01. Globals
 * 02. Forwards
 * 03. Events
 * 04. Functions
 */
 
// 00. Includes     
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdktools_functions>
#include <sdkhooks>
#include <clients>

// 01. Globals
#define GOVIP_MAINLOOP_INTERVAL 0.1
#define GOVIP_MAXPLAYERS 64

enum VIPState {
    
VIPState_WaitingForMinimumPlayers 0,
    
VIPState_Playing
};

new 
CurrentVIP 0;
new 
LastVIP 0;
new 
VIPState:CurrentState VIPState_WaitingForMinimumPlayers;
new 
Handle:CVarMinCT INVALID_HANDLE;
new 
Handle:CVarMinT INVALID_HANDLE;
new 
Handle:CVarVIPWeapon INVALID_HANDLE;
new 
Handle:CVarVIPhp INVALID_HANDLE;
new 
Handle:CVarVIPreward INVALID_HANDLE;
new 
MyWeaponsOffset 0;
new 
Handle:RescueZones INVALID_HANDLE;
new 
bool:RoundComplete false;
new 
winner 0;

// 02. Forwards
public OnPluginStart() {
    
CVarMinCT CreateConVar("govip_min_ct""2""Minimum number of CTs to play GOVIP");
    
CVarMinT CreateConVar("govip_min_t""1""Minimum number of Ts to play GOVIP");
    
CVarVIPWeapon CreateConVar("govip_weapon""weapon_p250""Weapon given to VIP");
    
CVarVIPhp CreateConVar("govip_health""200""VIP Base Health")
    
CVarVIPreward CreateConVar("govip_reward""2500""Money reward for winning by Escaping(CT) or killing the VIP(T)")
    
    
CurrentState VIPState_WaitingForMinimumPlayers;
    
    
CreateTimer(GOVIP_MAINLOOP_INTERVALGOVIP_MainLoopINVALID_HANDLETIMER_REPEAT);

    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeath);
    
    
MyWeaponsOffset FindSendPropInfo("CBaseCombatCharacter""m_hMyWeapons");
    
    
RescueZones CreateArray();
    
    
RoundComplete false;
}

public 
OnClientPutInServer(client) {
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
    return;
}

public 
OnClientDisconnect(client) {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP || RoundComplete) {
        return;
    }
    
    
RoundComplete true;
    
    
LastVIP CurrentVIP;
    
    
CurrentVIP 0;
    
    
PrintToChatAll("%s""[GO:VIP] The VIP has left, round ends in a draw.");
    
    
CS_TerminateRound(3.0CSRoundEnd_Draw);
    
winner 0;

}

public 
OnMapStart() {
    new 
String:buffer[512];
    
    
PrecacheModel("models/player/vip/stryker.mdl"true);
    
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eye.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_l.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_l.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_r.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/eyeball_r.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Diff.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Diff.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Norm.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Accessory_Spec.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_ao.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Diff.vmt");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Diff.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Norm.vtf");
    
AddFileToDownloadsTable("materials/models/player/vad36mk9/stryker/Stryker_Spec.vtf");
    
    
AddFileToDownloadsTable("models/player/vip/stryker.dx80.vtx");
    
AddFileToDownloadsTable("models/player/vip/stryker.dx90.vtx");
    
AddFileToDownloadsTable("models/player/vip/stryker.mdl");
    
AddFileToDownloadsTable("models/player/vip/stryker.phy");
    
AddFileToDownloadsTable("models/player/vip/stryker.sw.vtx");
    
AddFileToDownloadsTable("models/player/vip/stryker.vvd");
    
    new 
trigger = -1;
    while((
trigger FindEntityByClassname(trigger"trigger_multiple")) != -1) {
        
GetEntPropString(triggerProp_Data"m_iName"buffersizeof(buffer));
        if(
StrContains(buffer"vip_rescue_zone"false) == 0) {
            
SDKHook(triggerSDKHook_TouchTouchRescueZone);
        }
    }
    
    
ClearArray(RescueZones);
    
    
GetCurrentMap(buffersizeof(buffer));
    
    new 
Handle:kv CreateKeyValues("RescueZones");
    
    new 
String:path[1024];
    
BuildPath(Path_SMpathsizeof(path), "configs/rescue_zones.cfg");
    
    
FileToKeyValues(kvpath);
    
    if(
KvJumpToKey(kvbuffer)) {
        
KvGotoFirstSubKey(kv);
        
        do {
            new 
Float:radius KvGetFloat(kv"radius"200.0);
        
            
KvGetString(kv"coords"buffersizeof(buffer));
            new 
String:coords[3][128];
            
ExplodeString(buffer" "coords3128);

            
PrintToServer("[GO:VIP] Loading rescue zone at [%s, %s, %s] with radius of %f units."coords[0], coords[1], coords[2], radius);
                        
            new 
Handle:rescueZone CreateArray();
            
PushArrayCell(rescueZoneradius);
            
PushArrayCell(rescueZoneStringToFloat(coords[0]));
            
PushArrayCell(rescueZoneStringToFloat(coords[1]));
            
PushArrayCell(rescueZoneStringToFloat(coords[2]));
            
            
PushArrayCell(RescueZonesrescueZone);
        } while (
KvGotoNextKey(kv));
    }    
    
    
CloseHandle(kv);
}

// 03. Events
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) {
    
RoundComplete false;
    
CurrentVIP GetRandomPlayerOnTeam(CS_TEAM_CTLastVIP);
    new 
playercashoffs FindSendPropInfo("CCSPlayer""m_iAccount");
    
    if(
CurrentState != VIPState_Playing) {
        return 
Plugin_Continue;
    }
    
    for (new 
1<= MaxClientsi++) {
        
        if (
IsClientInGame(i) && IsPlayerAlive(i)) {
            new 
pl_team GetClientTeam(i);
            new 
iWeapon GetPlayerWeaponSlot(i4);
            new 
playercash GetEntData(iplayercashoffs);
            if (
iWeapon != -&& IsValidEdict(iWeapon)) {
                
decl String:szClassName[64];
                
GetEdictClassname(iWeaponszClassNamesizeof(szClassName));
                if (
StrEqual(szClassName"weapon_c4"false)) {
                    
RemovePlayerItem(iiWeapon);
                    
RemoveEdict(iWeapon);
                }
            }
            if (
winner == && pl_team == 2) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                
SetEntData(iplayercashoffscashreward);    
            }
            if (
winner == 22 && pl_team == 2) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                if (
playercash >= GetConVarInt(CVarVIPreward))
                {
                    
SetEntData(iplayercashoffscashreward);
                }
                else
                {
                    
SetEntData(iplayercashoffs0);
                }
            }
            if (
winner == 22 && pl_team == 3) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                
SetEntData(iplayercashoffscashreward);    
            }
            if (
winner == && pl_team == 3) {
                new 
cashreward playercash GetConVarInt(CVarVIPreward);
                if (
playercash >= GetConVarInt(CVarVIPreward))
                {
                    
SetEntData(iplayercashoffscashreward);
                }
                else
                {
                    
SetEntData(iplayercashoffs0);
                }
            }
        }
    }
        
    
RemoveMapObj();
        
    if(
CurrentVIP == || !IsValidPlayer(CurrentVIP)) {
        return 
Plugin_Continue;
    }
    
    new 
String:VIPName[128];
    
GetClientName(CurrentVIPVIPNamesizeof(VIPName));
    
    
PrintToChatAll("[GO:VIP] \"%s\" is the VIP, CTs protect the VIP from the Terrorists!"VIPName);
    
    new 
String:VIPWeapon[256];
    new 
basehp GetConVarInt(CVarVIPhp);
    
GetConVarString(CVarVIPWeaponVIPWeaponsizeof(VIPWeapon));
    new 
ArmorOffs FindSendPropInfo("CCSPlayer""m_ArmorValue");
    
    new 
index CreateEntityByName(VIPWeapon);
    
    
    if(
index != -1) {
        
StripWeapons(CurrentVIP);
        
SetEntityModel(CurrentVIP"models/player/vip/stryker.mdl");
        
GivePlayerItem(CurrentVIPVIPWeapon);
        
SetEntityHealth(CurrentVIPbasehp);
        
SetEntData(CurrentVIPArmorOffs125);    
    }    

    
    return 
Plugin_Continue;
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
    if(
CurrentState != VIPState_Playing) {
        return 
Plugin_Continue;
    }
    
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    
    if(
client != CurrentVIP || RoundComplete) {
        return 
Plugin_Continue;
    }
    
    
RoundComplete true;
    
winner 1;
    
    
CS_TerminateRound(3.0CSRoundEnd_TerroristWin);
    
    
PrintToChatAll("%s""[GO:VIP] The VIP has died, Terrorists win!");
    
    
LastVIP CurrentVIP;
    
    
CurrentVIP 0;
    
    return 
Plugin_Continue;
}

// 04. Functions
public Action:GOVIP_MainLoop(Handle:timer) {
    new 
CTCount GetTeamClientCount(CS_TEAM_CT);
    new 
TCount GetTeamClientCount(CS_TEAM_T);
    
    if(
CurrentState == VIPState_WaitingForMinimumPlayers) {
        if(
CTCount >= GetConVarInt(CVarMinCT) && TCount >= GetConVarInt(CVarMinT)) {
            
CurrentState VIPState_Playing;
            
PrintToChatAll("%s""[GO:VIP] Starting the game!");
            return 
Plugin_Continue;
        }
    }
    else if(
CurrentState == VIPState_Playing) {
        if(
TCount GetConVarInt(CVarMinT) || CTCount GetConVarInt(CVarMinCT)) {
            
CurrentState VIPState_WaitingForMinimumPlayers;
            
PrintToChatAll("%s""[GO:VIP] Game paused, waiting for more players.");
            return 
Plugin_Continue;
        }
        
        if(
CurrentVIP == && RoundComplete == false) {
            
RoundComplete true;
                
            
CurrentVIP GetRandomPlayerOnTeam(CS_TEAM_CTLastVIP);
            
winner 0;
            
            
CS_TerminateRound(3.0CSRoundEnd_GameStart); 
        }
        else if(!
RoundComplete && IsValidPlayer(CurrentVIP)) {
            new 
Float:vipOrigin[3];
            
GetClientAbsOrigin(CurrentVIPvipOrigin);
            
            new 
rescueZoneCount GetArraySize(RescueZones);
            
            for(new 
rescueZoneIndex 0rescueZoneIndex rescueZoneCountrescueZoneIndex++) {
                new 
Handle:rescueZone GetArrayCell(RescueZonesrescueZoneIndex);
                
                new 
Float:rescueZoneOrigin[3];
                
rescueZoneOrigin[0] = GetArrayCell(rescueZone1);
                
rescueZoneOrigin[1] = GetArrayCell(rescueZone2);
                
rescueZoneOrigin[2] = GetArrayCell(rescueZone3);
                
                new 
Float:rescueZoneRadius GetArrayCell(rescueZone0);
                
                if(
GetVectorDistance(rescueZoneOriginvipOrigin) <= rescueZoneRadius) {
                    
RoundComplete true;
                    
                    
LastVIP CurrentVIP;
                    
                    
winner 22;
                    
CS_TerminateRound(3.0CSRoundEnd_CTWin);
                    
                    
PrintToChatAll("%s""[GO:VIP] The VIP has been rescued, Counter-Terrorists win.");
                    
                    break;
                }
            }
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action:OnWeaponCanUse(clientweapon) {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP) {
        return 
Plugin_Continue;
    }
    
    new 
String:entityClassName[256];
    
    
GetEntityClassname(weaponentityClassNamesizeof(entityClassName));
    
    new 
String:VIPWeapon[256];
    
GetConVarString(CVarVIPWeaponVIPWeaponsizeof(VIPWeapon));
     
    if(
StrEqual(entityClassName"weapon_knife"false) || StrEqual(entityClassNameVIPWeaponfalse)) {
        return 
Plugin_Continue;
    }
    
    return 
Plugin_Handled;
}

public 
Action:Command_JoinTeam(client, const String:command[], argc)  {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP) {
        return 
Plugin_Continue;
    }
    
    
PrintToChat(client"%s""[GO:VIP] You are not allowed to change teams while you are the VIP.");
    return 
Plugin_Handled;
}

bool:IsValidPlayer(client) {
    if(!
IsValidEntity(client) || !IsClientConnected(client) || !IsClientInGame(client)) {
        return 
false;
    }
    
    return 
true;
}

GetRandomPlayerOnTeam(teamignore 0) {
    new 
teamClientCount GetTeamClientCount(team);
    
    if(
teamClientCount <= 0) {
        return 
0;
    }
    
    new 
client;
    
    do {
        
client GetRandomInt(1MaxClients);
    } while((
teamClientCount && client == ignore) || !IsClientInGame(client) || GetClientTeam(client) != team);
    
    return 
client;
}

stock RemoveMapObj() {
    
decl maxent,i;
    
decl String:Class[65];
    
maxent GetMaxEntities();
    for (
i=0;i<=maxent;i++)
    {
        if(
IsValidEdict(i) && IsValidEntity(i))
        {
            
GetEdictClassname(i, Class, sizeof(Class));
            if(
StrContains("func_bomb_target_hostage_entity_func_hostage_rescue",Class) != -1)
            {
                
RemoveEdict(i);
            }
        }
    }
}


StripWeapons(client) {
    new 
weaponID;

    for(new 
020= (4)) {
        
weaponID GetEntDataEnt2(clientMyWeaponsOffset x);
        
        if(
weaponID <= 0) {
            continue;
        }
        
        new 
String:weaponClassName[128];
        
GetEntityClassname(weaponIDweaponClassNamesizeof(weaponClassName));
        
        if(
StrEqual(weaponClassName"weapon_knife"false)) {
            continue;
        }

        
RemovePlayerItem(clientweaponID);
        
RemoveEdict(weaponID);
    }
}

public 
TouchRescueZone(triggerclient) {

    
    if(!
IsValidPlayer(client)) {
        return;
    } 

    if(
CurrentState != VIPState_Playing || client != CurrentVIP || RoundComplete) {
        return;
    }
    
    
winner 22;
    
    
RoundComplete true;
    
    
CS_TerminateRound(3.0CSRoundEnd_CTWin);
    
    
LastVIP CurrentVIP;

    
CurrentVIP 0;
    
    
PrintToChatAll("[GO:VIP] The VIP has been rescued, Counter-Terrorists win.");

I've compiled this with custom model for CS:GO and the two crucial things don't work:
- killing VIP doesn't end round (e.g slaying all other CTs)
- rescue zone doesn't work (tested on as_vertigo)

Only things that seem to work are:
- changing model for VIP
- VIP can only carry pistol and has 200 armor points (or HP, I can't remember)
- chat messages
Azet is offline
Lannister
Veteran Member
Join Date: Apr 2015
Old 02-10-2017 , 11:08   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #35

Could someone remake this plugin or fix it? this was a really really nice plugin from CS 1.6 that was even great in CS:S, it's sad that we don't have this in CS:GO!
Lannister is offline
viksando
New Member
Join Date: Feb 2011
Old 02-02-2018 , 10:59   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #36

Attachment 168347
Quote:
Originally Posted by Azet View Post
I've compiled this with custom model for CS:GO and the two crucial things don't work:
- killing VIP doesn't end round (e.g slaying all other CTs)
- rescue zone doesn't work (tested on as_vertigo)

Only things that seem to work are:
- changing model for VIP
- VIP can only carry pistol and has 200 armor points (or HP, I can't remember)
- chat messages
Have you set up your config/rescue_zones.cfg file correctly?
You have to input the coordinates and radius of the rescue zone for each map in this file for it to work.

Also CS:GO might have some different EVENT types than SOURCE, so... my code might not work on GO.
It would require extensive modification of the scoring system this plugin uses. Might be someone who
wants to make it for CSGO

Take a look at the RoundEnd event and its reasons, team indexes, etc. for csgo and compare. If something differs within the code, then it needs be changed to the correct value.

Here's how I've set up my rescue_zones.cfg file for some custom maps and it works without a hitch.

Code:
"RescueZones"
{		

	"as_oilrig"
	{
		"Rescue Zone"
		{
			"coords" "-568.66 -1258.23 464.03"
		}
	}
	"as_hiekka"
	{
		"Rescue Zone"
		{
			"coords" "-4492.53 1244.71 65.03"
		}
		"Rescue Zone"
		{
			"coords" "-3931.51 -1.33 -123.97"
		}
	}

	"as_isku"
	{
		"Rescue Zone"
		{
			"coords" "-283.29 -1205.43 20.03"
			"radius" "110"
		}
	}

}
That's addons/sourcemod/configs/rescue_zones.cfg

EDIT/P.S.:

The problem with no round ending on kill was prominent in CS:Source, and was apparently from a faulty line of code in the main function of the plugin. Everything works now. Here's the code:

PHP Code:
/**
 * 00. Includes
 * 01. Globals
 * 02. Forwards
 * 03. Events
 * 04. Functions
 */
 
// 00. Includes     
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#include <sdkhooks>
#include <clients>
#include <cstrike>

// 01. Globals
#define GOVIP_MAINLOOP_INTERVAL 0.1
#define GOVIP_MAXPLAYERS 64
#define IN  0x0001
#define OUT 0x0002

// We don't need them, since we #included <cstrike>,
// but if something goes wrong, uncomment them.
// #define CS_TEAM_CT 3
// #define CS_TEAM_T 2

enum VIPState {
    
VIPState_WaitingForMinimumPlayers 0,
    
VIPState_Playing
};

new 
CurrentVIP 0;
new 
LastVIP 0;
new 
VIPState:CurrentState VIPState_WaitingForMinimumPlayers;
new 
Handle:CVarMinCT INVALID_HANDLE;
new 
Handle:CVarMinT INVALID_HANDLE;
new 
Handle:CVarVIPWeapon INVALID_HANDLE;

// We're declaring the new cvars here:
new Handle:CVarVIPhp INVALID_HANDLE;
new 
Handle:CVarVIPreward INVALID_HANDLE;
new 
Handle:CVarVIParmor INVALID_HANDLE;
// End new cvar declaration

new MyWeaponsOffset 0;
new 
Handle:RescueZones INVALID_HANDLE;
new 
bool:RoundComplete false;

/* We're using this for proper monetary reward (on roundstart)
   if you think it's lame and I should use get event winner instead,
   feel free to change the code to your liking. */
new winner 0;
// End of monetary reward check.

// Obviously these variables would affect the scoring system.
// If you can code it better - be my guest.
new CTscore 0;
new 
t_incScore 0;
new 
ct_incScore 0;
// End of scoring variables declaration


// 02. Forwards
public OnPluginStart() {
    
CVarMinCT CreateConVar("govip_min_ct""2""Minimum number of CTs to play GOVIP");
    
CVarMinT CreateConVar("govip_min_t""1""Minimum number of Ts to play GOVIP");
    
CVarVIPWeapon CreateConVar("govip_weapon""weapon_p250""Weapon given to VIP");
    
CVarVIPhp CreateConVar("govip_health""200""VIP Base Health");
    
CVarVIPreward CreateConVar("govip_reward""2500""Money reward for winning by Escaping(CT) or killing the VIP(T)");
    
CVarVIParmor CreateConVar("govip_armor""100""VIP Base Armor");
    
    
CurrentState VIPState_WaitingForMinimumPlayers;

    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
    
HookEvent("round_end"Event_RoundEnd);
    new 
Handle:cvar_restartgame FindConVar("mp_restartgame");
    
HookConVarChange(cvar_restartgameConVarChanged_Restartgame);
    
    
MyWeaponsOffset FindSendPropInfo("CBaseCombatCharacter""m_hMyWeapons");
    
    
RescueZones CreateArray();
    
    
RoundComplete false;
}

public 
OnClientPutInServer(client) {
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
    return;
}

public 
OnClientDisconnect(client) {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP || RoundComplete) {
        return;
    }
    
    
RoundComplete true;
    
    
LastVIP CurrentVIP;
    
    
CurrentVIP 0;
    
    
PrintToChatAll("%s""[GO:VIP] The VIP has left, round ends in a draw.");
    
    
CS_TerminateRound(3.0CSRoundEnd_Draw);
    
winner 0;

}

public 
OnMapStart() {

    
t_incScore 0;
    
ct_incScore 0;
    
CTscore 0;

    new 
String:buffer[512];
    
    
PrecacheModel("models/player/vip/vip.mdl"true);
    
PrecacheSound("govip/com_eliminatevip.wav"true);
    
PrecacheSound("govip/com_killthatvip.wav"true);
    
PrecacheSound("govip/com_keepvipsafe.wav"true);
    
PrecacheSound("govip/com_protectvip.wav"true);
    
PrecacheSound("govip/vip_assassinated.wav"true);
    
PrecacheSound("govip/vip_escaped.wav"true);
    
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/body.vmt");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/body.vtf");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/body_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/head.vmt");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/head.vtf");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/head_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/head_s.vtf");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/hair.vmt");
    
AddFileToDownloadsTable("materials/models/player/stenli/aliens/bishop/hair.vtf");
    
    
AddFileToDownloadsTable("models/player/vip/vip.dx80.vtx");
    
AddFileToDownloadsTable("models/player/vip/vip.dx90.vtx");
    
AddFileToDownloadsTable("models/player/vip/vip.mdl");
    
AddFileToDownloadsTable("models/player/vip/vip.phy");
    
AddFileToDownloadsTable("models/player/vip/vip.sw.vtx");
    
AddFileToDownloadsTable("models/player/vip/vip.vvd");
    
    
AddFileToDownloadsTable("sound/govip/com_eliminatevip.wav");
    
AddFileToDownloadsTable("sound/govip/com_killthatvip.wav");
    
AddFileToDownloadsTable("sound/govip/com_keepvipsafe.wav");
    
AddFileToDownloadsTable("sound/govip/com_protectvip.wav");
    
AddFileToDownloadsTable("sound/govip/vip_assassinated.wav");
    
AddFileToDownloadsTable("sound/govip/vip_escaped.wav");
    
    new 
trigger = -1;
    while((
trigger FindEntityByClassname(trigger"trigger_multiple")) != -1) {
        
GetEntPropString(triggerProp_Data"m_iName"buffersizeof(buffer));
        if(
StrContains(buffer"vip_rescue_zone"false) == 0) {
            
SDKHook(triggerSDKHook_TouchTouchRescueZone);
        }
    }
    
    
ClearArray(RescueZones);
    
    
GetCurrentMap(buffersizeof(buffer));
    
    new 
Handle:kv CreateKeyValues("RescueZones");
    
    new 
String:path[1024];
    
BuildPath(Path_SMpathsizeof(path), "configs/rescue_zones.cfg");
    
    
FileToKeyValues(kvpath);
    
    if(
KvJumpToKey(kvbuffer)) {
        
KvGotoFirstSubKey(kv);
        
        do {
            new 
Float:radius KvGetFloat(kv"radius"200.0);
        
            
KvGetString(kv"coords"buffersizeof(buffer));
            new 
String:coords[3][128];
            
ExplodeString(buffer" "coords3128);

            
PrintToServer("[GO:VIP] Loading rescue zone at [%s, %s, %s] with radius of %f units."coords[0], coords[1], coords[2], radius);
                        
            new 
Handle:rescueZone CreateArray();
            
PushArrayCell(rescueZoneradius);
            
PushArrayCell(rescueZoneStringToFloat(coords[0]));
            
PushArrayCell(rescueZoneStringToFloat(coords[1]));
            
PushArrayCell(rescueZoneStringToFloat(coords[2]));
            
            
PushArrayCell(RescueZonesrescueZone);
        } while (
KvGotoNextKey(kv));
        
        
CreateTimer(GOVIP_MAINLOOP_INTERVALGOVIP_MainLoopINVALID_HANDLETIMER_REPEAT);
    }    
    else {
        
PrintToServer("[GO:VIP] Map has no rescue zones, cannot start.");
        
CurrentState VIPState_WaitingForMinimumPlayers;
    }
    
CloseHandle(kv);

}

// 03. Events
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) {
if (
CurrentState == VIPState_Playing) {
    for (new 
1<= MaxClientsi++) 
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
FreezePlayer(i);
        }
    }
    
    
// Begin scoring system
    
new roundwinner GetEventInt(event"winner");
    
    
// We're simply getting the reason for TerminateRound, then using hard-coded values for the scoring.
    // Not very 1337, but works like a bi0tch.
    
new winreason GetEventInt(event"reason");
    
    
// Now we set conditions and do simple math.
    
if (roundwinner == && winreason == 2) {
        
t_incScore++;
        
SetTeamScore(CS_TEAM_CTct_incScore);
        
SetTeamScore(CS_TEAM_Tt_incScore);
    }
    if (
roundwinner == && winreason == 7) {
        if (
ct_incScore CTscore) {
            
ct_incScore CTscore;
        }
        if (
ct_incScore >= CTscore) {
            
ct_incScore++;
            
CTscore ct_incScore;

        }
        
SetTeamScore(CS_TEAM_CTct_incScore);
        
SetTeamScore(CS_TEAM_Tt_incScore);
    }
    if (
roundwinner == && winreason == 1) {
        
ct_incScore++;
        
CTscore ct_incScore;
        
SetTeamScore(CS_TEAM_CTct_incScore);
        
SetTeamScore(CS_TEAM_Tt_incScore);
    }
    if (
winreason == 15 || winreason == 9) {
        
ct_incScore 0;
        
t_incScore 0;
        
CTscore 0;
    }
    
// End of scoring system.
}
return 
Plugin_Continue;
}
public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) {
    if(
CurrentState != VIPState_Playing) {
        
PrintToChatAll("[GO:VIP] Map has no rescue zones - cannot start.");
        
CurrentState VIPState_WaitingForMinimumPlayers;
        return 
Plugin_Continue;
    }
    else
    {
        
RoundComplete false;
        
CurrentVIP GetRandomPlayerOnTeam(CS_TEAM_CTLastVIP);
        new 
playercashoffs FindSendPropInfo("CCSPlayer""m_iAccount");
    
    
        for (new 
1<= MaxClientsi++) {
        
            if (
IsClientInGame(i) && IsPlayerAlive(i)) {
                
UnFreezePlayer(i);
                new 
pl_team GetClientTeam(i);
                new 
iWeapon GetPlayerWeaponSlot(i4);
                new 
playercash GetEntData(iplayercashoffs);
                new 
cashreward;
                if (
iWeapon != -&& IsValidEdict(iWeapon)) {
                    
decl String:szClassName[64];
                    
GetEdictClassname(iWeaponszClassNamesizeof(szClassName));
                    if (
StrEqual(szClassName"weapon_c4"false)) {
                        
RemovePlayerItem(iiWeapon);
                        
RemoveEdict(iWeapon);
                    }
                }
                if (
winner == && pl_team == 2) {
                    
PrintCenterText(i"Team, eliminate the VIP.");
                    
EmitSoundToClient(i"govip/com_eliminatevip.wav"____1.0______);
                }
                if (
winner == && pl_team == 3) {
                    
PrintCenterText(i"Keep the VIP safe.");
                    
EmitSoundToClient(i"govip/com_keepvipsafe.wav"____1.0______);
                }
                if (
winner == && pl_team == 2) {
                    
cashreward playercash GetConVarInt(CVarVIPreward);
                    
SetEntData(iplayercashoffscashreward);
                    
PrintCenterText(i"Team, eliminate the VIP.");
                    
EmitSoundToClient(i"govip/com_eliminatevip.wav"____1.0______);
                }
                if (
winner == 22 && pl_team == 2) {
                    
cashreward playercash GetConVarInt(CVarVIPreward);
                    if (
playercash >= GetConVarInt(CVarVIPreward))
                    {
                        
SetEntData(iplayercashoffscashreward);
                    }
                    else
                    {
                        
SetEntData(iplayercashoffs0);
                    }
                    
PrintCenterText(i"Kill that VIP at all costs!");
                    
EmitSoundToClient(i"govip/com_killthatvip.wav"____1.0______);
                }
                if (
winner == 22 && pl_team == 3) {
                    
cashreward playercash GetConVarInt(CVarVIPreward);
                    
SetEntData(iplayercashoffscashreward);
                    
PrintCenterText(i"Keep the VIP safe.");
                    
EmitSoundToClient(i"govip/com_keepvipsafe.wav"____1.0______);
                }
                if (
winner == && pl_team == 3) {
                    
cashreward playercash GetConVarInt(CVarVIPreward);
                    if (
playercash >= GetConVarInt(CVarVIPreward))
                    {
                        
SetEntData(iplayercashoffscashreward);
                    }
                    else
                    {
                        
SetEntData(iplayercashoffs0);
                    }
                    
PrintCenterText(i"Team, protect the VIP at all cost.");
                    
EmitSoundToClient(i"govip/com_protectvip.wav"____1.0______);
                }
            }
        }
        
        
RemoveMapObj();
        
        if(
CurrentVIP == || !IsValidPlayer(CurrentVIP)) {
            return 
Plugin_Continue;
        }
    
        new 
String:VIPName[128];
        
GetClientName(CurrentVIPVIPNamesizeof(VIPName));
    
        
PrintToChatAll("[GO:VIP] \"%s\" is the VIP, CTs protect the VIP from the Terrorists!"VIPName);
    
        new 
String:VIPWeapon[256];
        new 
basehp GetConVarInt(CVarVIPhp);
        new 
basearmor GetConVarInt(CVarVIParmor);

        
GetConVarString(CVarVIPWeaponVIPWeaponsizeof(VIPWeapon));
        new 
ArmorOffs FindSendPropInfo("CCSPlayer""m_ArmorValue");
        new 
HelmetOffs FindSendPropInfo("CCSPlayer""m_bHasHelmet");
        new 
PMIndex FindEntityByClassname(0"cs_player_manager");
    
        new 
index CreateEntityByName(VIPWeapon);
    
    
        if(
index != -1) {
            
StripWeapons(CurrentVIP);
            
SetEntityModel(CurrentVIP"models/player/vip/vip.mdl");
            
GivePlayerItem(CurrentVIPVIPWeapon);
            
SDKHook(PMIndexSDKHook_ThinkPostOnThinkPost);
            if (
basehp 1)
            {
                
SetEntityHealth(CurrentVIP1);
            }
            if (
basehp 200)
            {
                
SetEntityHealth(CurrentVIP200);
            }
            if (
basehp >=&& basehp <= 200)
            {
                
SetEntityHealth(CurrentVIPbasehp);
            }
            if (
basearmor 125)
            {
                
SetEntData(CurrentVIPArmorOffs125);
                
SetEntData(CurrentVIPHelmetOffs1);
            }
            if (
basearmor <= 125 && basearmor 0)
            {
                
SetEntData(CurrentVIPArmorOffsbasearmor);
                
SetEntData(CurrentVIPHelmetOffs1);
            }
            else
            {
                
SetEntData(CurrentVIPArmorOffs0);
                
SetEntData(CurrentVIPHelmetOffs0);
            }
        }
    
        
// You noticed? Leave it that way if you know what's good for your scoreboard.
        
SetTeamScore(CS_TEAM_Tt_incScore);
        
SetTeamScore(CS_TEAM_CTct_incScore);
        
// End of duplicate.
    
        
winner 0;
        return 
Plugin_Continue;
    }
}

public 
OnThinkPost(entity
{  
    
SetEntProp(entityProp_Send"m_iPlayerVIP"CurrentVIP); 
}  

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
    if(
CurrentState != VIPState_Playing) {
        return 
Plugin_Continue;
    }
    
    
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    
    if(
client != CurrentVIP || RoundComplete) {
        return 
Plugin_Continue;
    }
    
    
RoundComplete true;
    
winner 1;
    
    
CS_TerminateRound(3.0CSRoundEnd_VIPKilled);
    for (new 
1<= MaxClientsi++)
    {
    if (
IsClientInGame(i)) {
            
EmitSoundToClient(i"govip/vip_assassinated.wav"____1.0______);
        }
    }    
    
PrintCenterTextAll("VIP has been assassinated!");
    
    
PrintToChatAll("%s""[GO:VIP] The VIP has died, Terrorists win!");
    
    
LastVIP CurrentVIP;
    
    
CurrentVIP 0;
    
    return 
Plugin_Continue;
}

// 04. Functions
public Action:GOVIP_MainLoop(Handle:timer) {
    new 
CTCount GetTeamClientCount(CS_TEAM_CT);
    new 
TCount GetTeamClientCount(CS_TEAM_T);
    
    if(
CurrentState == VIPState_WaitingForMinimumPlayers) {
        if(
CTCount >= GetConVarInt(CVarMinCT) && TCount >= GetConVarInt(CVarMinT)) {
            
CurrentState VIPState_Playing;
            
PrintToChatAll("%s""[GO:VIP] Starting the game!");
            
CS_TerminateRound(3.0CSRoundEnd_GameStart);
            return 
Plugin_Continue;
        }
    }
    else if(
CurrentState == VIPState_Playing) {
        if(
TCount GetConVarInt(CVarMinT) || CTCount GetConVarInt(CVarMinCT)) {
            
CurrentState VIPState_WaitingForMinimumPlayers;
            
PrintToChatAll("%s""[GO:VIP] Game paused, waiting for more players.");
            return 
Plugin_Continue;
        }
        
        if(
CurrentVIP == && RoundComplete == false) {
            
RoundComplete true;
                
            
CurrentVIP GetRandomPlayerOnTeam(CS_TEAM_CTLastVIP);
            
winner 0;
            
            
CS_TerminateRound(3.0CSRoundEnd_GameStart); 
        }
        else if(!
RoundComplete && IsValidPlayer(CurrentVIP)) {
            new 
Float:vipOrigin[3];
            
GetClientAbsOrigin(CurrentVIPvipOrigin);
            
            new 
rescueZoneCount GetArraySize(RescueZones);
            
            for(new 
rescueZoneIndex 0rescueZoneIndex rescueZoneCountrescueZoneIndex++) {
                new 
Handle:rescueZone GetArrayCell(RescueZonesrescueZoneIndex);
                
                new 
Float:rescueZoneOrigin[3];
                
rescueZoneOrigin[0] = GetArrayCell(rescueZone1);
                
rescueZoneOrigin[1] = GetArrayCell(rescueZone2);
                
rescueZoneOrigin[2] = GetArrayCell(rescueZone3);
                
                new 
Float:rescueZoneRadius GetArrayCell(rescueZone0);
                
                if(
GetVectorDistance(rescueZoneOriginvipOrigin) <= rescueZoneRadius) {
                    
RoundComplete true;
                    
EmitSoundToAll("govip/vip_escaped.wav"____1.0______);
                    
                    
LastVIP CurrentVIP;
                    
                    
winner 22;

                    
CS_TerminateRound(3.0CSRoundEnd_VIPEscaped);
                    for (new 
1<= MaxClientsi++)
                    {
                    if (
IsClientInGame(i)) {
                            
EmitSoundToClient(i"govip/vip_escaped.wav"____1.0______);
                        }
                    }    
                    
PrintCenterTextAll("The VIP Escaped!");
                    
                    
PrintToChatAll("%s""[GO:VIP] The VIP has been rescued, Counter-Terrorists win.");
                    
                    break;
                }
            }
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action:OnWeaponCanUse(clientweapon) {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP) {
        return 
Plugin_Continue;
    }
    
    new 
String:entityClassName[256];
    
    
GetEntityClassname(weaponentityClassNamesizeof(entityClassName));
    
    new 
String:VIPWeapon[256];
    
GetConVarString(CVarVIPWeaponVIPWeaponsizeof(VIPWeapon));
     
    if(
StrEqual(entityClassName"weapon_knife"false) || StrEqual(entityClassNameVIPWeaponfalse)) {
        return 
Plugin_Continue;
    }
    
    return 
Plugin_Handled;
}

public 
Action:Command_JoinTeam(client, const String:command[], argc)  {
    if(
CurrentState != VIPState_Playing || client != CurrentVIP) {
        return 
Plugin_Continue;
    }
    
    
PrintToChat(client"%s""[GO:VIP] You are not allowed to change teams while you are the VIP.");
    return 
Plugin_Handled;
}

bool:IsValidPlayer(client) {
    if(!
IsValidEntity(client) || !IsClientConnected(client) || !IsClientInGame(client)) {
        return 
false;
    }
    
    return 
true;
}

GetRandomPlayerOnTeam(teamignore 0) {
    new 
teamClientCount GetTeamClientCount(team);
    
    if(
teamClientCount <= 0) {
        return 
0;
    }
    
    new 
client;
    
    do {
        
client GetRandomInt(1MaxClients);
    } while((
teamClientCount && client == ignore) || !IsClientInGame(client) || GetClientTeam(client) != team);
    
    return 
client;
}

stock RemoveMapObj() {
    
decl maxent,i;
    
decl String:Class[65];
    
maxent GetMaxEntities();
    for (
i=0;i<=maxent;i++)
    {
        if(
IsValidEdict(i) && IsValidEntity(i))
        {
            
GetEdictClassname(i, Class, sizeof(Class));
            if(
StrContains("func_bomb_target_hostage_entity_func_hostage_rescue",Class) != -1)
            {
                
RemoveEdict(i);
            }
        }
    }
}


StripWeapons(client) {
    new 
weaponID;

    for(new 
020= (4)) {
        
weaponID GetEntDataEnt2(clientMyWeaponsOffset x);
        
        if(
weaponID <= 0) {
            continue;
        }
        
        new 
String:weaponClassName[128];
        
GetEntityClassname(weaponIDweaponClassNamesizeof(weaponClassName));
        
        if(
StrEqual(weaponClassName"weapon_knife"false)) {
            continue;
        }

        
RemovePlayerItem(clientweaponID);
        
RemoveEdict(weaponID);
    }
}

public 
TouchRescueZone(triggerclient) {

    
    if(!
IsValidPlayer(client)) {
        return;
    } 

    if(
CurrentState != VIPState_Playing || client != CurrentVIP || RoundComplete) {
        return;
    }
    
    
winner 22;
    
RoundComplete true;
    
    
CS_TerminateRound(6.0CSRoundEnd_VIPEscaped);
    for (new 
1<= MaxClientsi++)
    {
    if (
IsClientInGame(i)) {
            
EmitSoundToClient(i"govip/vip_escaped.wav"____1.0______);
        }
    }    
    
PrintCenterTextAll("The VIP Escaped!");
    
    
LastVIP CurrentVIP;

    
CurrentVIP 0;

    
PrintToChatAll("[GO:VIP] The VIP has been rescued, Counter-Terrorists win.");
}

public 
FreezePlayer(client)
{
    
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"0.0);
    
SetEntityRenderColor(client2550170174);
    
ScreenFade(client0002552OUT);
}

public 
UnFreezePlayer(client)
{
    
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"1.0);
    
SetEntityRenderColor(client255255255255);
}

public 
ScreenFade(clientredgreenbluealphadelaytype)
{
    new 
Handle:msg;
    new 
duration;
    
    
duration delay 1000;
    
    
msg StartMessageOne("Fade"client);
    
BfWriteShort(msg500);
    
BfWriteShort(msgduration);
    
BfWriteShort(msgtype);
    
BfWriteByte(msgred);
    
BfWriteByte(msggreen);
    
BfWriteByte(msgblue);
    
BfWriteByte(msgalpha);
    
EndMessage();
}

public 
ConVarChanged_Restartgame(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if (
String:oldValue[0] == String:newValue[0])
    {
        return;
    }
    else
    {
        
t_incScore 0;
        
ct_incScore 0;
        
CTscore 0;
    }

Files are below. All sounds/models included. Change as you like. GL & HF!

If anyone needs help/walk-u-thru fixing the plugin for csgo and is able to test it ingame, contact me here: [email protected]
I don't own CS:GO nor CS:GO server, so I can't code and test.
Attached Files
File Type: zip go_vip_sourcemod.zip (5.04 MB, 200 views)

Last edited by viksando; 02-02-2018 at 12:03.
viksando is offline
API
Veteran Member
Join Date: May 2006
Old 03-03-2018 , 11:27   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #37

Cool This is still being worked on.
The biggest challenge I always faced was figuring out how to make bots understand how to play the gamemode correctly. I wanted to parse NAV files at some point and control bots from the server, but it seems like a really difficult task even years later. Parsing the NAV files was pretty easy, and I released the source somewhere around here a while back. Someone even ported it to SourceMod.
__________________
API is offline
Send a message via AIM to API
viksando
New Member
Join Date: Feb 2011
Old 04-14-2018 , 16:35   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #38

Quote:
Originally Posted by pimpinjuice View Post
Cool This is still being worked on.
The biggest challenge I always faced was figuring out how to make bots understand how to play the gamemode correctly. I wanted to parse NAV files at some point and control bots from the server, but it seems like a really difficult task even years later. Parsing the NAV files was pretty easy, and I released the source somewhere around here a while back. Someone even ported it to SourceMod.
I hear you, though what you say suggests that commanding the bots through the server would require more than a simple plugin for sourcemod. I'm not sure how this could be done with a plugin, as we do not have any tangible bot control functions in the sourcemod scripting libraries. So that would probably reqiure reverse-engineering the cstrike bots element... and also a lot of work on sourcemod itself. I'm not a programmer, but I think that your question should be directed towards the sourcemm/sourcemod devs.
viksando is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 05-20-2023 , 21:40   Re: [CS:GO] VIP Mode - GO:VIP
Reply With Quote #39

https://forums.alliedmods.net/showthread.php?t=315113

It's generally not good to make everything manual, there should be a code for the mappers, and making a hostage rescue zone also enablers bot integration by placing a hostage close to it but unreachable.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 05-20-2023 at 21:40.
eyal282 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode