#define blue 0 #define red 1 #define green 2 #define yellow 3 #define blue_color 0x33CCFFAA #define red_color 0xAA3333AA #define green_color 0x12900BBF #define yellow_color 0xFFFF00AA
new gTeam[MAX_PLAYERS];
public OnGameModeInit()
{
AddPlayerClass(287, 1382.8832,794.5979,10.8280,177.3541, 33, 1000, 24, 1000, 25, 1000);//blue
AddPlayerClass(124, 754.6019,274.7502,27.3949,3.6705, 33, 1000, 24, 1000, 25, 1000);//Red
AddPlayerClass(73, -468.3686,-91.8865,60.0957,348.3795, 33, 1000, 24, 1000, 25, 1000);//Green
AddPlayerClass(117, 1019.3360,-287.2638,73.9931,178.4066, 33, 1000, 24, 1000, 25, 1000);//Yellow
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(classid == 0) {
SetPlayerSkin(playerid, 287); //skin for team blue
GameTextForPlayer(playerid,"~B~Blue",1000,4);
SetPlayerColor(playerid, blue_color);//color for team blue
gTeam[playerid] = 1; //class 0 will be ally of class 1
}
if(classid == 1) {
SetPlayerSkin(playerid, 124); //skin for team red
GameTextForPlayer(playerid,"~R~Red",1000,4);//color for team red
SetPlayerColor(playerid, red_color);
gTeam[playerid] = 0; //class 1 will be ally of class 0
}
if(classid == 2) {
SetPlayerSkin(playerid, 73); //skin for team green
GameTextForPlayer(playerid,"~G~Green",1000,4);
SetPlayerColor(playerid, green_color);//color for team green
gTeam[playerid] = 3;//class 2 will be ally of class 3
}
if(classid == 3) {
SetPlayerSkin(playerid, 117); //skin for team yellow
GameTextForPlayer(playerid,"~Y~Yellow",1000,4);
SetPlayerColor(playerid, yellow_color);//color for team yellow
gTeam[playerid] = 2;//class 3 will be ally of class 2
}
return 1;
}
public OnPlayerSpawn(playerid)
{
new Skin=GetPlayerSkin(playerid);
switch(Skin)
{
case 287,117: //The Skins Which Will Be Ally
{
SetPlayerTeam(playerid,Blue);//Team Blue And Its Ally Like Blue And Red They Cant Kill Each Other
}
case 73,124: //The Skins Which Will Be Ally
{
SetPlayerTeam(playerid,Green);//Team Green And Its Ally Like Green And Yellow
}
}
return 1;
}
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
if ( Shooter != INVALID_PLAYER_ID )
{
if ( GetPlayerTeam( Target ) == GetPlayerTeam( Shooter ) )
{
new Float:hp;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
}
}
return 1;
}
|
You could use OnPlayerShootPlayer https://sampforum.blast.hk/showthread.php?tid=195439
Code:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
if ( Shooter != INVALID_PLAYER_ID )
{
if ( GetPlayerTeam( Target ) == GetPlayerTeam( Shooter ) )
{
new Float:hp;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
}
}
return 1;
}
|
|
Why does one start every word with a capital letter? It makes one look either incredibly stupid or incredibly ignorant.
Pro tip: do not write tutorials if you are "new to scripting". If you write a tutorial you are saying: "I am qualified to write about this matter", but clearly you are not. Assumptions, duplicated code and the fact that SA-MP has this functionality built in (AddPlayerClassEx, GetPlayerTeam, SetPlayerTeam). You're not even using "gTeam" at all. You assign it a value, but then what? |