• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Tutorial] Command /ZKill

Joined
Apr 2, 2013
Messages
1,098
Reaction score
4,625






Search for:

PHP:
if(strncmp(cmd, "/sv", 3) == 0 && plr->profile_.ProfileData.isDevAccount)
        return Cmd_SetVitals(plr, cmd);

Add:

PHP:
if(strncmp(cmd, "/zkill", 3) == 0 && plr->profile_.ProfileData.isDevAccount)     return Cmd_KillZombie(plr, cmd);

Above of:

PHP:
int ServerGameLogic::Cmd_SetVitals(obj_ServerPlayer* plr, const char* cmd)
{
    char buf[128];
    int v1, v2, v3, v4;


    if(5 != sscanf(cmd, "%s %d %d %d %d", buf, &v1, &v2, &v3, &v4))
        return 2;


    plr->loadout_->Health = (float)v1;
    plr->loadout_->Hunger = (float)v2;
    plr->loadout_->Thirst = (float)v3;
    plr->loadout_->Toxic  = (float)v4;
    return 0;
}

Add:

PHP:
int ServerGameLogic::Cmd_KillZombie(obj_ServerPlayer* plr, const char* cmd)
{
    char buf[128];
    int x;
   
    if(2 != sscanf(cmd, "%s %d", buf, &x))
        return 2;


    ObjectManager& GW = GameWorld();
    for (GameObject *targetObj = GW.GetFirstObject(); targetObj; targetObj = GW.GetNextObject(targetObj))
    {
        if(targetObj->isObjType(OBJTYPE_Zombie))
        {
            obj_Zombie* z = (obj_Zombie*)targetObj;
            float dist = (plr->GetPosition() - targetObj->GetPosition()).Length();
           
            if(dist < x)
            {
                z->ApplyDamage(plr, 100, 1, storecat_MELEE);
            }
        }
    }


    return 0;
}

Search for:

PHP:
int          Cmd_SetVitals(obj_ServerPlayer* plr, const char* cmd);

Add:

PHP:
int          Cmd_KillZombie(obj_ServerPlayer* plr, const char* cmd);
How to use:

Command: /zkill [distance]

Exemple: /zkill 500

will kill all zombies 500 meters
:p:​
 
Last edited:
Junior Spellweaver
Joined
Sep 4, 2013
Messages
153
Reaction score
49
Re: [Release] Command /ZKill

Thanks +1 Waiting for fly releaseeee :D
 
Joined
Apr 2, 2013
Messages
1,098
Reaction score
4,625
WarZTHSrc2 V2

I have not tried it in warzth source, but try this code

PHP:
int ServerGameLogic::Cmd_KillZombie(obj_ServerPlayer* plr, const char* cmd)
{
    char buf[128];
    int x;
    
    if(2 != sscanf(cmd, "%s %d", buf, &x))
        return 2;




    ObjectManager& GW = GameWorld();
    for (GameObject *targetObj = GW.GetFirstObject(); targetObj; targetObj = GW.GetNextObject(targetObj))
    {
        if(targetObj->isObjType(OBJTYPE_Zombie))
        {
            obj_Zombie* z = (obj_Zombie*)targetObj;
            float dist = (plr->GetPosition() - targetObj->GetPosition()).Length();
            
            if(dist < x)
            {
                z->ApplyDamage(plr, 100, 1, storecat_MELEE, 0);
            }
        }
    }




    return 0;
}
 
Last edited:
Joined
Apr 23, 2013
Messages
1,172
Reaction score
1,797
I have not tried it in warzth source, but try this code

Code:
int ServerGameLogic::Cmd_KillZombie(obj_ServerPlayer* plr, const char* cmd)
{
    char buf[128];
    int x;
    
    if(2 != sscanf(cmd, "%s %d", buf, &x))
        return 2;




    ObjectManager& GW = GameWorld();
    for (GameObject *targetObj = GW.GetFirstObject(); targetObj; targetObj = GW.GetNextObject(targetObj))
    {
        if(targetObj->isObjType(OBJTYPE_Zombie))
        {
            obj_Zombie* z = (obj_Zombie*)targetObj;
            float dist = (plr->GetPosition() - targetObj->GetPosition()).Length();
            
            if(dist < x)
            {
                z->ApplyDamage(plr, 100, 1, storecat_MELEE, 1);
            }
        }
    }




    return 0;
}

yes it worked, thanks man.
I did not see where he was the difference '-'


==============
Code:
[COLOR=#0000BB]int ServerGameLogic[/COLOR][COLOR=#007700]::[/COLOR][COLOR=#0000BB]Cmd_[/COLOR][COLOR=#ff0000]SpawnZombie[/COLOR][COLOR=#0000BB][/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]obj_ServerPlayer[/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]plr[/COLOR][COLOR=#007700], const [/COLOR][COLOR=#0000BB]char[/COLOR][COLOR=#007700]* [/COLOR][COLOR=#0000BB]cmd[/COLOR][COLOR=#007700])[/COLOR]
I just get that code to spawn zombies?
Give all the rest myself was, = 0 because it is easy to give
 
Junior Spellweaver
Joined
Apr 3, 2014
Messages
135
Reaction score
23
I can't find int Cmd_SetVitals(obj_ServerPlayer* plr, const char* cmd);
 
Back
Top