#1

Hello there, well, i'm currently working on a zombie gamemode, but i'm not sure of what I should do for this:

When the player spawns, he won't be able to move, as he have to choose a team by himself.
The problem is that, when exemple he type /zombie, I need that like, he's "infos" been set as a Zombie.
Due that later on, you won't be able to do "x" command if your not a zombie.

Here is the code.

Код:
 	if (strcmp("/zombie", cmdtext, true, 10) == 0)
	{
      ResetPlayerWeapons(playerid);
      SetPlayerInterior(playerid, 0);
	  SetPlayerPos(playerid,-2768.17,-715.08,65.84);
      SendClientMessage(playerid,0x0000BBAA, "Need tips? Type /zombiehelp!");
      GivePlayerWeapon(playerid, 33, 150);
      SetPlayerSkin( playerid, 287 );
      return 1;
	}

I know that i need to do something like "new IsZombie", but i'm really confused.
Thanks in advance!
Reply
#2

You can create a global variable (at the top, under "#include <a_samp>"):
pawn Код:
new IsZombie[MAX_PLAYERS];
And them set them as a zombie as such:
pawn Код:
IsZombie[playerid] = 1;
Or you can use PVar:
pawn Код:
SetPVarInt(playerid, "IsZombie", 1);
And check if they are a zombie with:
pawn Код:
if(GetPVarInt(playerid, "IsZombie") == 1)
Reply
#3

SetPVarInt is exactly what I needed! Thanks alot mate!

----------

EDIT:

Here I have a problem. Actually, I did a command /zombie & /human.
By typing one of these commands you will be a zombie & vice-versa.
But now, if I type /human I still can spawn as a Human even if i'm a zombie.
Here's the code:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/zombie", cmdtext, true, 10) == 0)
    {
      SetPVarInt(playerid, "IsZombie", 1);
      ResetPlayerWeapons(playerid);
      SetPlayerInterior(playerid, 0);
      SetPlayerPos(playerid,-2768.17,-715.08,65.84);
      SendClientMessage(playerid,0x0000BBAA, "Need tips? Type /zombiehelp!");
      GivePlayerWeapon(playerid, 33, 150);
      SetPlayerSkin( playerid, 287 );
      return 1;
    }
   
    if (strcmp("/human", cmdtext, true, 10) == 0)
    {
        ResetPlayerWeapons(playerid);
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid,-2768.17,-715.08,65.84);
        SendClientMessage(playerid,0x0000BBAA, "Need tips? Type /humanhelp!");
        GivePlayerWeapon(playerid, 33, 150);
        SetPlayerSkin( playerid, 17 );
        return 1;
    }
    else if(GetPVarInt(playerid, "IsZombie") == 1)
    {
        SendClientMessage(playerid,COLOR_RED, "You are a zombie, you canno't switch!");
        return 1;
    }
    return 0;
}
Reply
#4

pawn Код:
if (strcmp("/human", cmdtext, true, 10) == 0)
{
    if(GetPVarInt(playerid, "IsZombie") == 0)
    {
        ResetPlayerWeapons(playerid);
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid,-2768.17,-715.08,65.84);
        SendClientMessage(playerid,0x0000BBAA, "Need tips? Type /humanhelp!");
        GivePlayerWeapon(playerid, 33, 150);
        SetPlayerSkin( playerid, 17 );
        return 1;
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED, "You are a zombie, you canno't switch!");
        return 1;
    }
}
What's the /human command for anyway? If players start as a human and zombies cannot change into humans, who will use this command?
Reply
#5

Quote:
Originally Posted by Finn
Посмотреть сообщение
pawn Код:
if (strcmp("/human", cmdtext, true, 10) == 0)
{
    if(GetPVarInt(playerid, "IsZombie") == 0)
    {
        ResetPlayerWeapons(playerid);
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid,-2768.17,-715.08,65.84);
        SendClientMessage(playerid,0x0000BBAA, "Need tips? Type /humanhelp!");
        GivePlayerWeapon(playerid, 33, 150);
        SetPlayerSkin( playerid, 17 );
        return 1;
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED, "You are a zombie, you canno't switch!");
        return 1;
    }
}
What's the /human command for anyway? If players start as a human and zombies cannot change into humans, who will use this command?
It's because i'm not using OnPlayerRequestClass, as there will be many features on the gamemode and that it's needed as it this for it. Could you help now? ^^ Thanks.
Reply
#6

My code didn't work, or?
Reply
#7

Oops, didnt see it, sorry, let me try ^^
Edit: Thanks, fully worked!
Reply
#8

-Bump
Код:
C:\Users\vince\Desktop\Project Zombie\gamemodes\pzombie.pwn(316) : warning 202: number of arguments does not match definition
pawn Код:
else if(GetPVarInt(playerid, "classid",0) == 1)
        {
            SendClientMessage(playerid,COLOR_RED, "-Access Denied-");
            return 1;
        }

Also, when someone enters the safezone it does "has entered the safezone" and not "Vince has entered the safezone" :S

Thanks in advance, and thanks for all of that help!
Reply
#9

GetPVarInt only uses 2 params, so:
pawn Код:
GetPVarInt(playerid, "classid")
And we can't help you with your second problem without seeing the code :P. You may not be getting the players name correctly, or you may not be formatting the string correctly.
Reply
#10

Quote:
Originally Posted by Zezombia
Посмотреть сообщение
GetPVarInt only uses 2 params, so:
pawn Код:
GetPVarInt(playerid, "classid")
And we can't help you with your second problem without seeing the code :P. You may not be getting the players name correctly, or you may not be formatting the string correctly.
Oh here it is:
pawn Код:
if (strcmp("/enter", cmdtext, true, 10) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0,-1233.5388,-2331.3735,18.2380))
        {
            new string[128];
            SetPlayerPos(playerid,2263.7610,-2323.9080,323.6542);
            format(string,sizeof(string),"%s has entered the safezone!",playerid);
            SendClientMessageToAll(COLOR_WHITE,string);
            return 1;
        }
        else if(GetPVarInt(playerid, "classid",0) == 1)
        {
            SendClientMessage(playerid,COLOR_RED, "-Access Denied-");
            return 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_LIGHTBLUE, "You are not at the safezone! Be careful!");
            return 1;
        }
    }
And for GetPVarInt, actually I canno't just put "classid" as there is multiple class ids, i tried with classid1 but it get everything fucked up.

Thanks in advance!

EDIT: Nevermind, I figured out that that on
pawn Код:
SendClientMessageToAll(COLOR_WHITE,string);
I was missing "playerid" xD Where should I put it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)