PDA

View Full Version : Team Mates System! Need Help...


iOmar
18/06/2012, 01:00 PM
I want Team system. That you can't kill your Team Mates. The bullets will not Damage them. I have These Team. I will glad if you help me...

#define TEAM_PAKISTAN 0
#define TEAM_GERMANY 1
#define TEAM_USA 2
#define TEAM_RUSSIA 3
#define TEAM_INDIA 4

[MM]RoXoR[FS]
18/06/2012, 01:07 PM
#define TEAM_PAKISTAN 0
#define TEAM_GERMANY 1
#define TEAM_USA 2
#define TEAM_RUSSIA 3
#define TEAM_INDIA 4

static gTeam[MAX_PLAYERS];




public SetPlayerToTeamColor(playerid)
{
if(gTeam[playerid] == TEAM_PAKISTAN) {
SetPlayerColor(playerid,TEAM_PAKISTAN_COLOR);
} else if(gTeam[playerid] == )......//and so on for all teams
}
}


public SetPlayerTeamFromClass(playerid,classid)
{
// Set their team number based on the class they selected.
if(classid == 0 )
{
gTeam[playerid] = TEAM_PAKISTAN;
SetPlayerTeam(playerid,TEAM_PAKISTAN);
}

else if(classid == 1)
{
//so on for all teams
}

iOmar
18/06/2012, 01:53 PM
I did this:

public SetPlayerToTeamColor(playerid)
{
if(gTeam[playerid] == TEAM_PAKISTAN) {
SetPlayerColor(playerid,0x008000FF);
} else if(gTeam[playerid] ==TEAM_GERMANY) {
SetPlayerColor(playerid,ORANGE);
} else if(gTeam[playerid] ==TEAM_USA) {
SetPlayerColor(playerid,BLUE);
} else if(gTeam[playerid] ==TEAM_RUSSIA) {
SetPlayerColor(playerid,RED);
} else if(gTeam[playerid] ==TEAM_INDIA) {
SetPlayerColor(playerid,YELLOW);
}
}

It is giving this warning:
E:\UDCSER~1\GAMEMO~1\Wars.pwn(778) : warning 235: public function lacks forward declaration (symbol "SetPlayerToTeamColor")
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.

Faisal_khan
18/06/2012, 02:03 PM
forward SetPlayerToTeamColor(playerid);

Avi57
18/06/2012, 02:07 PM
Warning Never Matters...............
Try Starting it...........

iOmar
18/06/2012, 02:07 PM
I only used SETPLAYERTEAMTOCOLOR. Not SetplayerTeamFromClass. So will it work??

One More Thing. i have Fly cmd. And only admin of level 5 or 5+ can use it. But i want That Admin of level 5 or 5+ can only use if they are on duty.. Little Help Please:

CMD:fly(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
StartFly(playerid);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be on level 5 to use this CMD");
return 1;
}
CMD:stopfly(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
StopFly(playerid);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be on level 5 to use this CMD");
return 1;
}

Here is Onduty And offduty CMD:

CMD:onduty(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
SetPlayerSkin(playerid,217);
GivePlayerWeapon(playerid,38,500000);
SetPlayerHealth(playerid,999999999);
SetPlayerArmour(playerid,999999999);
SetPlayerColor(playerid,COLOR_PINK);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"ADM CMD: %s is Now On An Admin Duty",pName);
SendClientMessageToAll(0xFF66FFAA,string);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You are not Administrator of Level 2");
return 1;
}

CMD:offduty(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
ResetPlayerWeapons(playerid);
ForceClassSelection(playerid);
SetPlayerHealth(playerid,0);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"ADM CMD: %s is End With His Admin Duty",pName);
SendClientMessageToAll(0xFF66FFAA,string);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You are not Administrator of Level 2");
return 1;
}

[MM]RoXoR[FS]
18/06/2012, 02:47 PM
You shoudl use SetplayerTeamFromClass if you want specific skins to be of specific teams.

In your duty command I could not find a variable that tells us if an admin is currently on duty or not.
For that you may create enum or a global variable.
i will show you with enum (as you can easily edit it after)

Declaring enum

enum PlayerInfo
{
pDuty,
}

new pInfo[MAX_PLAYERS][PlayerInfo];



CMD:onduty(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
SetPlayerSkin(playerid,217);
GivePlayerWeapon(playerid,38,500000);
SetPlayerHealth(playerid,999999999);
SetPlayerArmour(playerid,999999999);
SetPlayerColor(playerid,COLOR_PINK);
pInfo[playerid][pDuty] = 1; //Player is now on duty
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"ADM CMD: %s is Now On An Admin Duty",pName);
SendClientMessageToAll(0xFF66FFAA,string);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You are not Administrator of Level 2");
return 1;
}

CMD:offduty(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
pInfo[playerid][pDuty] = 0;//Player is off duty
ResetPlayerWeapons(playerid);
ForceClassSelection(playerid);
SetPlayerHealth(playerid,0);
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"ADM CMD: %s is End With His Admin Duty",pName);
SendClientMessageToAll(0xFF66FFAA,string);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You are not Administrator of Level 2");
return 1;
}


Now, lets make your fly command.

CMD:fly(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
if (pInfo[playerid][pDuty] == 0) return SendClientMessage(playerid, COLOR_RED,"ERROR: You must be on duty to use this cmd.");
else StartFly(playerid);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be on level 5 to use this CMD");
return 1;
}
CMD:stopfly(playerid,parmas[])
{
if(IsPlayerLuxAdminLevel(playerid,2))
{
StopFly(playerid);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be on level 5 to use this CMD");
return 1;
}

iOmar
18/06/2012, 05:20 PM
Roxor Bro i am not understanding SETPLAYERTEAMTOCLASS. Please define it more clearly... :) I shall be very thank full to you..

Faisal_khan
19/06/2012, 01:15 AM
Roxor Bro i am not understanding SETPLAYERTEAMTOCLASS. Please define it more clearly... :) I shall be very thank full to you..

As the name suggests, SetPlayerTeamToClass will set the players team to the team which he selected in the skin/team selection.

iOmar
19/06/2012, 03:24 AM
public SetPlayerTeamFromClass(playerid,classid)
{
if(classid == 0 )
{
gTeam[playerid] = TEAM_PAKISTAN;
SetPlayerTeam(playerid,TEAM_PAKISTAN);
}

else if(classid == 1)
{
gTeam[playerid] = TEAM_GERMANY;
SetPlayerTeam(playerid,TEAM_GERMANY);
}

else if(classid == 2)
{
gTeam[playerid] = TEAM_USA;
SetPlayerTeam(playerid,TEAM_USA);
}

else if(classid == 3)
{
gTeam[playerid] = TEAM_RUSSIA;
SetPlayerTeam(playerid,TEAM_RUSSIA);
}
else if(classid == 4)
{
gTeam[playerid] = TEAM_INDIA;
SetPlayerTeam(playerid,TEAM_INDIA);
}
}

Giving This Error:

E:\UDCSER~1\GAMEMO~1\Wars.pwn(1736) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

Faisal_khan
19/06/2012, 05:44 AM
I never used forward in my script:
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 268.4988,1884.0615,-30.0938);
SetPlayerFacingAngle(playerid, 184.2539);
SetPlayerCameraPos(playerid, 268.5090,1880.9513,-30.3906);
SetPlayerCameraLookAt(playerid, 268.4988,1884.0615,-30.0938);
SetPlayerTeamFromClass(playerid, classid);
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
gTeam[playerid] = EU;
GameTextForPlayer(playerid,"~b~EU",2,1);
}
if(classid == 1)
{
gTeam[playerid] = PAC;
GameTextForPlayer(playerid,"~g~PAC",2,1);
}
}

SetPlayerToTeamColor(playerid)
{
if(gTeam[playerid] == EU)
{
SetPlayerColor(playerid,COLOR_EU);
}
if(gTeam[playerid] == PAC)
{
SetPlayerColor(playerid,COLOR_PAC);
}
}

iOmar
19/06/2012, 06:59 AM
Thanks For Help. I Did This:
stock SetPlayerTeamFromClass(playerid,classid);
stock SetPlayerToTeamColor(playerid);

public SetPlayerTeamFromClass(playerid,classid)
{
if(classid == 0 )
{
gTeam[playerid] = TEAM_PAKISTAN;
SetPlayerTeam(playerid,TEAM_PAKISTAN);
}

else if(classid == 1)
{
gTeam[playerid] = TEAM_GERMANY;
SetPlayerTeam(playerid,TEAM_GERMANY);
}

else if(classid == 2)
{
gTeam[playerid] = TEAM_USA;
SetPlayerTeam(playerid,TEAM_USA);
}

else if(classid == 3)
{
gTeam[playerid] = TEAM_RUSSIA;
SetPlayerTeam(playerid,TEAM_RUSSIA);
}
else if(classid == 4)
{
gTeam[playerid] = TEAM_INDIA;
SetPlayerTeam(playerid,TEAM_INDIA);
}
}

public SetPlayerToTeamColor(playerid)
{
if(gTeam[playerid] == TEAM_PAKISTAN) {
SetPlayerColor(playerid,0x008000FF);
} else if(gTeam[playerid] ==TEAM_GERMANY) {
SetPlayerColor(playerid,ORANGE);
} else if(gTeam[playerid] ==TEAM_USA) {
SetPlayerColor(playerid,BLUE);
} else if(gTeam[playerid] ==TEAM_RUSSIA) {
SetPlayerColor(playerid,RED);
} else if(gTeam[playerid] ==TEAM_INDIA) {
SetPlayerColor(playerid,YELLOW);
}
}

Faisal_khan
19/06/2012, 07:06 AM
No you can't put stock like that stock is for function not for callback. You must forward it. Did it gave you anyway errors?

iOmar
19/06/2012, 07:17 AM
no. thats why i put it>.. So it won't work??

Faisal_khan
19/06/2012, 07:19 AM
Try it out. If not works post here.

iOmar
19/06/2012, 07:41 AM
I'll try it out as soon as my friend will come. Now its compiling fine with forward.. Look i did this now:

forward SetPlayerTeamFromClass(playerid,classid);

forward SetPlayerToTeamColor(playerid);

rachit_rocks
19/06/2012, 07:48 AM
E:\UDCSER~1\GAMEMO~1\Wars.pwn(1736) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
This means that this is because of the skins and the teams.

Your teams are not set to be like that I think.

Faisal_khan
19/06/2012, 08:56 AM
I'll try it out as soon as my friend will come. Now its compiling fine with forward.. Look i did this now:

forward SetPlayerTeamFromClass(playerid,classid);

forward SetPlayerToTeamColor(playerid);
Ok Wish you luck!