Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] Command /ZKill

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






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,468
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,735
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