11.04.2012, 20:58
Eu queria fazer uma funзгo para que tivesse mais uma funзгo neste comando. Pois ele tem somente o retirar/guardar mais eu queria adicionar o atirar e fazer o jogador levar o choque, mais isso aconteзe se o cara bater no outro com o taser poderia ter um geito de fazer o disparo somente com o comando /tazer atingir id.
Cуdigo do OnPlayerKeyStateChange
pawn Код:
if(strcmp(cmd, "/tazer", true) ==0)
{
if(IsPlayerConnected(playerid))
{
new x_job[20];
x_job = strtok(cmdtext, idx);
if(!strlen(x_job))
{
SendClientMessage(playerid, COLOR_WHITE, "USE: /tazer [retirar/guardar]");
return 1;
}
tmp = strtok(cmdtext, idx);
if(strcmp(x_job,"retirar",true) == 0)
{
PlayerHasTazer[playerid] = 1;
SetPlayerAttachedObject(playerid, 0, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);
format(string, sizeof(string), "* %s retirou seu taser do coldre.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else if(strcmp(x_job,"guardar",true) == 0)
{
PlayerHasTazer[playerid] = 0;
RemovePlayerAttachedObject(playerid, 0);
format(string, sizeof(string), "* %s guardou seu taser no coldre.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
return 1;
}
pawn Код:
if ((newkeys & KEY_FIRE))
{
if(PlayerHasTazer[playerid] == 1)
{
ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
new victimid = GetClosestPlayer(playerid);
if(IsPlayerConnected(victimid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
{
new Float:health;
GetPlayerHealth(victimid, health);
SetPlayerHealth(victimid, health - 5.0);
new string[128];
TogglePlayerControllable(i, 0);
format(string, sizeof(string), "* You were tazed by %s for 8 seconds.", PlayerName(playerid));
SendClientMessage(i, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* You tazed %s for 8 seconds.", PlayerName(i));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s shoots with his tazer at %s, and tazed him.", PlayerName(playerid) ,PlayerName(i));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
ApplyAnimation(i, "PED","FLOOR_hit_f", 4.0, 1, 0, 0, 0, 0);
return 1;
}
}
}
}
}