20.08.2016, 06:36
here you go :-
download zcmd and sscanf include. it will make your work easier. I used them for this script and this should work. (REMEMBER it is untested!)
Код:
#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; }