Applying a IF condition
#1

Hello, i was making a gangzone turf wars for my gm i applied a condition here
Quote:

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == Checkpoint[GZONE])
{

if(gTeam[playerid] == tCP[GZONE]) return SendClientMessage(playerid,0xFFFFFF,"This turf is already captured by your team.");
timer[playerid][GZONE] = SetTimerEx("SetZone",30000,false,"i",playerid);
SendClientMessage(playerid,0xFFFFFF,"Wait for 45 sec to take over the Turf ");
iCP[playerid] = GZONE;
}

But Server acctually refusses the condition "if(gTeam[playerid] == tCP[GZONE]) return SendClientMessage(playerid,0xFFFFFF,"This turf is already captured by your team.");"

Any help?
Reply
#2

Give us more data. Like for example "How you set up the GZone & iCP"
Reply
#3

Quote:

new Zone[30];

new timer[MAX_PLAYERS][30];
new iCP[MAX_PLAYERS];//To check player went in which CP.
new tCP[30];

Ongamemodint....
Quote:

Checkpoint[GZONE] = CreateDynamicCP(2528.2610,-1668.1365,15.1692,2,-1,-1,-1);
Zone[GZONE] = GangZoneCreateEx(2370.609, -1728.326, 2522.421, -1634.903, 1, 1.0);

Quote:

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == Checkpoint[GZONE])
{
// if(tCP[GZONE] == gTeam[playerid]) return SendClientMessage(playerid,0xFFFFFF,"This is already captured by your team.");
if(gTeam[playerid] == tCP[GZONE]) return SendClientMessage(playerid,0xFFFFFF,"This turf is already captured by your team.");
timer[playerid][GZONE] = SetTimerEx("SetZone",30000,false,"i",playerid);
SendClientMessage(playerid,0xFFFFFF,"Wait for 45 sec to take over the Turf ");
iCP[playerid] = GZONE;
}
/* if(checkpointid == Checkpoint[GAS])
{
if(tCP[GAS] == gTeam[playerid]) return SendClientMessage(playerid,0xFFFFFF,"This is already captured by your team.");
timer[playerid][GAS] = SetTimerEx("SetZone",2000,false,"i",playerid);
SendClientMessage(playerid,0xFFFFFF,"You enter GAS CP");
iCP[playerid] = GAS;
}
*/
return 1;
}

public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
if(checkpointid == Checkpoint[GZONE])
{
KillTimer(timer[playerid][GZONE]);
iCP[playerid] = -1;//None
}
/* if(checkpointid == Checkpoint[GAS])
{
KillTimer(timer[playerid][GAS]);
SendClientMessage(playerid,0xFFFFFF,"You left GAS CP");
iCP[playerid] = -1;
}
*/
return 1;
}
forward SetZone(playerid);
public SetZone(playerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
GivePlayerMoney(playerid,3000);
SendClientMessage(playerid,COLOR_GREEN,"Congratula tion! You have Gained 3 Scores & 3000$ Money ");
SetGangZone(playerid);
return 1;
}

Quote:

forward SetGangZone(playerid);public SetGangZone(playerid)
{
if(gTeam[playerid] == TEAM_GROVE)
{
GangZoneShowForAll(Zone[GAS],COLOR_GREEN);

new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For GROVE",pName);
SendClientMessageToAll(0x008000AA,string);
}

if(gTeam[playerid] == TEAM_AZTECA)
{
GangZoneShowForAll(Zone[GAS],COLOR_LIGHTBLUE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For AEZATECAS",pName);
SendClientMessageToAll(0x008000AA,string);
}

if(gTeam[playerid] == TEAM_POLICE)
{
GangZoneShowForAll(Zone[GAS],COLOR_BLUE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For POLICE",pName);
SendClientMessageToAll(0x008000AA,string);
}

if(gTeam[playerid] == TEAM_BALLAS)
{
GangZoneShowForAll(Zone[GAS],COLOR_PURPLE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For BALLA",pName);
SendClientMessageToAll(0x008000AA,string);
}

if(gTeam[playerid] == TEAM_TRIADS)
{
GangZoneShowForAll(Zone[GAS],RED);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For TRIAD",pName);
SendClientMessageToAll(0x008000AA,string);
}

if(gTeam[playerid] == TEAM_VAGOS)
{
GangZoneShowForAll(Zone[GZONE],COLOR_YELLOW);

new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For VAGOS",pName);
SendClientMessageToAll(0x008000AA,string);
}

if(gTeam[playerid] == TEAM_DANANG)
{
GangZoneShowForAll(Zone[GZONE],COLOR_OLIVE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For DANANG",pName);
SendClientMessageToAll(0x008000AA,string);
}

if(gTeam[playerid] == TEAM_MAFIA)
{
GangZoneShowForAll(Zone[GZONE],COLOR_MAROON);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For MAFIA",pName);
SendClientMessageToAll(0x008000AA,string);
}

return 1;
}

Reply
#4

Instead of [ Qoute ]
use
[ Pawn ]

[ /Pawn ]

Just a quick tip makes its more readable
Reply
#5

Try
pawn Код:
if(tCP[GZONE] == gTeam[playerid]) return SendClientMessage(playerid,0xFFFFFF,"This turf is already captured by your team.");"
Don't forget to +Rep if helped.
Reply
#6

pawn Код:
forward SetGangZone(playerid);public SetGangZone(playerid)
{
if(gTeam[playerid] == TEAM_GROVE)
{
GangZoneShowForAll(Zone[GAS],COLOR_GREEN);

new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For GROVE",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

if(gTeam[playerid] == TEAM_AZTECA)
{
GangZoneShowForAll(Zone[GAS],COLOR_LIGHTBLUE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For AEZATECAS",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

if(gTeam[playerid] == TEAM_POLICE)
{
GangZoneShowForAll(Zone[GAS],COLOR_BLUE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For POLICE",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

if(gTeam[playerid] == TEAM_BALLAS)
{
GangZoneShowForAll(Zone[GAS],COLOR_PURPLE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For BALLA",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

if(gTeam[playerid] == TEAM_TRIADS)
{
GangZoneShowForAll(Zone[GAS],RED);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured GasStation For TRIAD",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

if(gTeam[playerid] == TEAM_VAGOS)
{
GangZoneShowForAll(Zone[GZONE],COLOR_YELLOW);

new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For VAGOS",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

if(gTeam[playerid] == TEAM_DANANG)
{
GangZoneShowForAll(Zone[GZONE],COLOR_OLIVE);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For DANANG",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

if(gTeam[playerid] == TEAM_MAFIA)
{

GangZoneShowForAll(Zone[GZONE],COLOR_MAROON);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Server News: %s has captured Satellite For MAFIA",pName);
SendClientMessageToAll(0x008000AA,string);
tCP[GZONE] = gTeam[playerid];
}

return 1;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)