NEED NEW CODE OF INFECTING FOR ZOMBIES(will give Rep for Help)
#1

Ok i need some help with my gamemod. im making Humans Vs. Zombies TDM
I have 12 teams 5 teams comes under survivors and other 5 comes under the infected.
Humans - Civil,Sheriff.cop,Swat,Fbi,army
Zombies - Zombie,Runner,Smoker,Hunter,Witch,Xmutant
Код:
#define CIVIL   0
#define SHERIFF 1
#define POLICE  2
#define SWAT    3
#define FBI     4
#define ARMY    5
#define ZOMBIE  6
#define RUNNER  7
#define SMOKER  8
#define HUNTER  9
#define WITCH   10
#define XMUTANT 11
new gTeam[MAX_PLAYERS];
Everything like Team colors and spawns have been added and working properly....
note:that i added more than 1 skin for each team so i used ''AddPlayerClassEx"

Now i Really need a code to make all zombie teams infect human teams .... And Not other zombie teams...
like Zombie teams like :zombie,Runner,Smoker,Hunter,Witch,Xmutant can Infect all human teams... but not other zombies teams.... the zombies should get 2 score fore one kill

for eg. something like this....
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_FIRE)
    {
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(i, X, Y, Z);
            if(gTeam[playerid] == 0)
            {
                if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
                {
                    if(gTeam[i] != 0)
                    {
                        new Float:H;
                        GetPlayerHealth(i, H);
                        SetPlayerHealth(i, H-10);
                        SetPVarInt(playerid, "Infected", 1);        
                        if(GetPVarInt(playerid,"Infected") == 0)
                        {
                            GameTextForPlayer(i, "~r~Infected!", 500, 3);
                        }

                    }
                }
            }
        }
    }
    return 1;
}
pls dont link any tutorials... there isnt any tutorial based on this... Thanks in advance !
Reply
#2

LOW YOUR F*CKING CAPS DUDE.
low your caps ..
anyways post this in Script Request Thread 5# this section which is not assigned with scripting requests is not just for giving codes.
Reply
#3

I dont think that this belongs to script request as he already got a code

First to make the definition of the teams easier you could use an enum
pawn Код:
enum { // enum creates a list of constant variables, by default incremented by 1 each time (start at 0)
    CIVIL, // 0
    SHERIFF, // 1
    POLICE, // 2
    SWAT, // ...
    FBI,
    ARMY,
    ZOMBIE
    // the other zombie teams
}
Now lets make an easy macro to check if the player is a human or a zombie

pawn Код:
#define IsPlayerHuman(%0) (gTeam[(%0)] < ZOMBIE) // every team defined under (numerical) zombie is human
#define IsPlayerZombie(%0) (IsPlayerHuman(%0) == false) // self-explanatory
So now you only need to use that macro in your code

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE) // & instead of == | explanation => https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
    {
        if(IsPlayerZombie(playerid)) // I moved the zombie check outside, since it doesnt need any loop variable
        {
            new Float:X, Float:Y, Float:Z, Float:H; // create variables before the loop
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                if(IsPlayerHuman(i) && GetPlayerPos(i, X, Y, Z) && IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
                { // just put all if checks together
                    GetPlayerHealth(i, H);
                    SetPlayerHealth(i, H-10);
                    if(GetPVarInt(i,"Infected") == 0) // i not playrid
                    {
                        SetPVarInt(i, "Infected", 1); // "" and should be inside here
                        GameTextForPlayer(i, "~r~Infected!", 500, 3) // I removed the semicolon of this line to be sure that you read the comments and readd it again :), also remove the comments if you want
                    }
                }
            }
        }
    }
    return 1;
}
Just read the comments if you want to know what I changed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)