new headshot[MAX_PLAYERS];
//-----------------------------------HEADSHOT-----------------------------------
if(strcmp(cmd, "/ahs", true) == 0)
{
new activeheadshot;
tmp = strtok(cmdtext, idx);
activeheadshot = strval(tmp);
if(logged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use that command.");
return 1;
}
if(PlayerInfo[playerid][pAdmin] < 2)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not an admin!");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /ahs [0/1]");
return 1;
}
if(activeheadshot > 1 || activeheadshot < 0)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must enter 1 or 0 to activate or deactivate headshots.");
return 1;
}
if(activeheadshot == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
headshot[i]=1;
}
dini_IntSet("server.ini","headshot", activeheadshot);
SendClientMessage(playerid, COLOR_ORANGE, "You have enabled headshots for everyone.");
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "Admin %s enabled headshots !", sendername);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "~w~HEADSHOT ENABLED");
GameTextForAll(string, 5000, 3 );
return 1;
}
if(activeheadshot == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
headshot[i]=0;
}
dini_IntSet("server.ini","headshot", activeheadshot);
GetPlayerName(playerid, sendername, sizeof(sendername));
SendClientMessage(playerid, COLOR_ORANGE, "You have disabled headshots for everyone.");
format(string, sizeof(string), "Admin %s disabled headshots !", sendername);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "~w~HEADSHOT DISABLED");
GameTextForAll(string, 5000, 3);
return 1;
}
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
if(headshot[playerid] == 1)
{
if(damagedid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 9)
{
SetPlayerHealth(damagedid, 0.0);
}
if(damagedid != INVALID_PLAYER_ID && weaponid == 33 && bodypart == 9)
{
SetPlayerHealth(damagedid, 0.0);
}
if(damagedid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
{
SetPlayerHealth(damagedid, 0.0);
}
}
return 1;
}
#include <a_samp> #include <zcmd> #include <sscanf> new headshot[MAX_PLAYERS]; //-----------------------------------HEADSHOT----------------------------------- CMD:ahs(playerid, parmas[]) { new activeheadshot; new text[128]; if(logged[playerid] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use that command."); if(PlayerInfo[playerid][pAdmin] < 2)return SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not an admin!"); if(sscanf(parmas, "i", activeheadshot)) returnSendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /ahs [0/1]"); if(activeheadshot > 1 || activeheadshot < 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must enter 1 or 0 to activate or deactivate headshots."); for(new i = 0; i < MAX_PLAYERS; i++) { if(activeheadshot == 1) { headshot[i] = 1; dini_IntSet("server.ini","headshot", activeheadshot); SendClientMessage(playerid, COLOR_ORANGE, "You have enabled headshots for everyone."); GetPlayerName(playerid, sendername, sizeof(sendername)); format(string, sizeof(string), "Admin %s enabled headshots !", sendername); SendClientMessageToAll(COLOR_WHITE, string); format(string, sizeof(string), "~w~HEADSHOT ENABLED"); GameTextForAll(string, 5000, 3 ); return 1; } if(activeheadshot == 0) { headshot[i] = 0; dini_IntSet("server.ini","headshot", activeheadshot); GetPlayerName(playerid, sendername, sizeof(sendername)); SendClientMessage(playerid, COLOR_ORANGE, "You have disabled headshots for everyone."); format(string, sizeof(string), "Admin %s disabled headshots !", sendername); SendClientMessageToAll(COLOR_WHITE, string); format(string, sizeof(string), "~w~HEADSHOT DISABLED"); GameTextForAll(string, 5000, 3); return 1; } } return 1; } public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart) { if(headshot[playerid] == 1) { if(damagedid != INVALID_PLAYER_ID) { if(bodypart == 9) { if(weaponid == 24 || weaponid == 33 || weaponid == 34) { SetPLayerHealth(damagedid, 0.0); } } } } } return 1; }
new hstoggle = 1;
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/hstoggle", true))
{
if(logged[playerid] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use that command.");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not an admin!");
switch(hstoggle)
{
case 0: hstoggle = 1, GameTextForAll("Headshots Enabled!", 5000, 3);
case 1: hstoggle = 0, GameTextForAll("Headshots Disabled!", 5000, 3);
}
return 1;
}
return 0;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
if(hstoggle == 1 && damagedid != INVALID_PLAYER_ID && bodypart == 9 && (weaponid == 24 || weaponid == 33 || weaponid == 34)) SetPlayerHealth(damagedid, 0.0);
return 1;
}
new hstoggle = 1;
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/hstoggle", true))
{
if(logged[playerid] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use that command.");
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not an admin!");
switch(hstoggle)
{
case 0: hstoggle = 1, GameTextForAll("Headshots Enabled!", 5000, 3);
case 1: hstoggle = 0, GameTextForAll("Headshots Disabled!", 5000, 3);
}
return 1;
}
return 0;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(hstoggle == 1 && issuerid != INVALID_PLAYER_ID && bodypart == 9 && (weaponid == 24 || weaponid == 33 || weaponid == 34)) SetPlayerHealth(playerid, 0);
return 1;
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(activeheadshot == 1)
{
headshot[i] = 1;
dini_IntSet("server.ini","headshot", activeheadshot);
SendClientMessage(playerid, COLOR_ORANGE, "Vous avez activй le headshot pour tout le monde.");
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "L'admin %s a activй les headshots. (Eagle, Rifle, Sniper)", sendername);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "~w~HEADSHOT ACTIVE");
GameTextForAll(string, 5000, 3 );
return 1;
}
if(activeheadshot == 0)
{
headshot[i] = 0;
dini_IntSet("server.ini","headshot", activeheadshot);
GetPlayerName(playerid, sendername, sizeof(sendername));
SendClientMessage(playerid, COLOR_ORANGE, "Vous avez dйsactivй le headshot pour tout le monde.");
format(string, sizeof(string), "Ladmin %s a dйsactivй les headshots.", sendername);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "~r~HEADSHOT DESACTIVE");
GameTextForAll(string, 5000, 3);
return 1;
}
}
BUMP.
Here is the code I use, headshot works but even after disabled and works only for id 0. pawn Код:
|
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(activeheadshot == 1)
{
headshot[i] = 1;
dini_IntSet("server.ini","headshot", activeheadshot);
SendClientMessage(playerid, COLOR_ORANGE, "Vous avez activй le headshot pour tout le monde.");
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "L'admin %s a activй les headshots. (Eagle, Rifle, Sniper)", sendername);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "~w~HEADSHOT ACTIVE");
GameTextForAll(string, 5000, 3 );
}
if(activeheadshot == 0)
{
headshot[i] = 0;
dini_IntSet("server.ini","headshot", activeheadshot);
GetPlayerName(playerid, sendername, sizeof(sendername));
SendClientMessage(playerid, COLOR_ORANGE, "Vous avez dйsactivй le headshot pour tout le monde.");
format(string, sizeof(string), "Ladmin %s a dйsactivй les headshots.", sendername);
SendClientMessageToAll(COLOR_WHITE, string);
format(string, sizeof(string), "~r~HEADSHOT DESACTIVE");
GameTextForAll(string, 5000, 3);
}
}
return 1;}