Command failure?
#1

Код:
	if(!strcmp(cmdtext,"/arm",true)) {
	new classid;
	if(IsPlayerInCheckpoint(playerid))
 	{
	if(classid == 0 || classid == 1 || classid == 2)
  {
	SendClientMessageToAll(COLOR_GREEN,"Team 1 has planted their bomb!");
 	}
 	if (classid == 3 || classid == 4 || classid == 5)
 	{
	SendClientMessageToAll(COLOR_GREEN,"Team 2 has planted their bomb!");
	}
	else
	{
	SendClientMessage(playerid,COLOR_RED,"Your Not in the checkpoint!");
	}
	}
	return 1;
	}
Suppost to check if the player is in a checkpoint. then announce if that team set their bomb. but so far. you type /arm outside of a checkpoint. it does nothing. do /arm inside a checkpoint ti says im not in one. any idea of how i got this backwards?
Reply
#2

IsPlayerInCheckpoint needs to be like this:

if(IsPlayerInCheckpoint(playerid) == checkpointid)
Reply
#3

There is no checkpoint id's.... im not using a streamer
Reply
#4

Quote:
Originally Posted by _Ч§hмf†ҐЧ™_
There is no checkpoint id's.... im not using a streamer
yes but every checkpoint still needs a ID to be assigned to it so it can verify that its THAT checkpoint that they are at
Reply
#5

And how would i do that?
Код:
cp1 = CreateCheckpoint
like that?
Reply
#6

GUYS PLEASE STOP TELLING BULLSHIT, ups caps

SetPlayerCheckpoint only returns 1 if the checkpoint was created and 0 for not
IsPlayerInCheckpoint only checks if the player is in the checkpoint (and only one at the same time can exist)

Topic:
You got a bracket problem and the class thing wont work because you create the variable classid local (and never change it) so it is always zero

Use gTeam, the native team functions or the new pVars

Here an example with pVars (because I like friendly fire - the native function disable it )
pawn Код:
//These macros will overwrite the existing native functions!
#define SetPlayerTeam(%0,%1) SetPVarInt(%2, "TEAM_VAR", %1)
#define GetPlayerTeam(%0) GetPVarInt(%0, "TEAM_VAR")
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    switch(classid)
    {
        case 0..2: SetPlayerTeam(playerid, 1); //Team 1
        case 3..5: SetPlayerTeam(playerid, 2); //Team 2
    }
}
pawn Код:
//OnPlayerCommandText
    if(!strcmp(cmdtext,"/arm",true))
    {
        if(IsPlayerInCheckpoint(playerid))
        {
            if(GetPlayerTeam(playerid) == 1)
            {
                SendClientMessageToAll(COLOR_GREEN,"Team 1 has planted their bomb!");
            } else { //if he isnt in team 1 he must be in team 2
                SendClientMessageToAll(COLOR_GREEN,"Team 2 has planted their bomb!");
            }
        } else {
            SendClientMessage(playerid,COLOR_RED,"Your Not in the checkpoint!");
        }
        return 1;
    }
Reply
#7

Ok i understand it now. And this server will have two checkpoints. but only team 1 see's theirs. and team two see's theirs. will this still do the same?


EDIT: it works!

Also, how would i make a command only useable if it's near a certain cord?
Reply
#8

Quote:
Originally Posted by _Ч§hмf†ҐЧ™_
Also, how would i make a command only useable if it's near a certain cord?
use IsPlayerInRangeOfPoint (example included)
Reply
#9

mmk, and how would i make it have a point for each team, use gTeam?
Reply
#10

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(GetPlayerTeam(playerid) == 1)
    {
        SetPlayerCheckpoint(playerid, X, Y, Z);
    } else {
        SetPlayerCheckpoint(playerid, X, Y, Z);
    }
}
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(GetPlayerTeam(playerid) == 1)
    {
        //code for team 1
    } else {
        //code for team 2
    }
}
just replace GetPlayerTeam(playerid) with gteam[playerid]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)