PDA

View Full Version : god,headshot


crukk11
11/04/2017, 01:23 PM
i have problem with my command god for admin, when the player shot to head admin and admin die

this my command god


CMD:god(playerid, params[])
{
//new str3[128];
new str1[128], str2[128], admin[MAX_PLAYER_NAME], p[MAX_PLAYER_NAME], id, Float: health1, Float:health2;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command");


GetPlayerHealth(playerid, health1);


if(sscanf(params, "d", id))
{
if (health1==0.0)
{
SetPlayerHealth(playerid, 100.0);
return SendClientMessage(playerid,0x00FF00AA, "Back to mortality.");
}

if (health1>0.0)
{
SetPlayerHealth(playerid, FLOAT_INFINITY);
return SendClientMessage(playerid, 0x00FF00AA, "You are god now!");
}
}

if(IsPlayerConnected(id))
{
GetPlayerName(playerid, admin, MAX_PLAYER_NAME);
GetPlayerName(id, p, MAX_PLAYER_NAME);
GetPlayerHealth(id, health2);

if (health2>0.0)
{
SetPlayerHealth(id, FLOAT_INFINITY);
format(str2, sizeof(str2), "You have successfully turned %s into god.", p);
SendClientMessage(playerid, 0x00FF00AA, str2);
format(str1, sizeof(str1), "Admin %s has turned you into god!", admin);
SendClientMessage(id, 0x00FF00AA, str1);
}

if (health2==0)
{
SetPlayerHealth(id, 100.0);
format(str2, sizeof(str2), "You have turned god %s into human.", p);
SendClientMessage(playerid, 0x00FF00AA, str2);
return SendClientMessage(id, 0x00FF00AA, "Back to mortality.");
}
}
else SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
return 1;
}

and this the code headshot

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID && bodypart == 9)
{
if(IsPlayerConnected(issuerid))
{
if(bodypart == 9 && PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid))
{
SetPlayerHealth(playerid, 0.0);
new string[100], pname[24];
GetPlayerName(playerid, headshot, sizeof(headshot));
GetPlayerName(issuerid, pname, sizeof(pname));
format(string, sizeof(string), "%s(%i) was shoot to the Head by %s(%i)", headshot,playerid, pname, issuerid);
GivePlayerMoney(issuerid, 100);
SendClientMessageToAll(0x800000AA,string);
GameTextForPlayer(issuerid,"~r~HeadShot",2000,1);
PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid,"~r~HeadShot",2000,1);
ApplyAnimation(playerid, "PED", "ko2", 4.1, 1, 1, 1, 1, 1, 1); // applying the dead guy animation tho you can one your own.
PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0);
}
}
}
return 1;
}

help

AndreiWow
11/04/2017, 01:27 PM
Why do you use this

if(sscanf(params, "d", id))
{
if (health1==0.0)
{
SetPlayerHealth(playerid, 100.0);
return SendClientMessage(playerid,0x00FF00AA, "Back to mortality.");
}

if (health1>0.0)
{
SetPlayerHealth(playerid, FLOAT_INFINITY);
return SendClientMessage(playerid, 0x00FF00AA, "You are god now!");
}
}


if you have this


if(IsPlayerConnected(id))
{
GetPlayerName(playerid, admin, MAX_PLAYER_NAME);
GetPlayerName(id, p, MAX_PLAYER_NAME);
GetPlayerHealth(id, health2);

if (health2>0.0)
{
SetPlayerHealth(id, FLOAT_INFINITY);
format(str2, sizeof(str2), "You have successfully turned %s into god.", p);
SendClientMessage(playerid, 0x00FF00AA, str2);
format(str1, sizeof(str1), "Admin %s has turned you into god!", admin);
SendClientMessage(id, 0x00FF00AA, str1);
}

if (health2==0)
{
SetPlayerHealth(id, 100.0);
format(str2, sizeof(str2), "You have turned god %s into human.", p);
SendClientMessage(playerid, 0x00FF00AA, str2);
return SendClientMessage(id, 0x00FF00AA, "Back to mortality.");
}
}
else SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
return 1;

crukk11
11/04/2017, 01:35 PM
to give player to be godemode

AndreiWow
11/04/2017, 01:36 PM
I see that you are checking if the player is a RCON admin, but you are not checking if the player "pAdmin" variable is 1 or higher when using /god command.

As I see from the onplayertakedamage code, it should only work if the pAdmin variable of the player is smaller than 1, so maybe who got headshotted did not have this variable on.

Also you used
|| !IsPlayerAdmin

which means "If player is not admin rcon then he can get a headshot"

crukk11
11/04/2017, 01:41 PM
how i to make command work without to get headshot

AndreiWow
11/04/2017, 01:43 PM
Your admins should have "pAdmin" equal or higher than 1...

crukk11
11/04/2017, 01:50 PM
where the code or the the onplayertakedamage

AndreiWow
11/04/2017, 02:13 PM
Do you have a command to make someone admin?

crukk11
11/04/2017, 02:16 PM
no. should i remove padmin

AndreiWow
11/04/2017, 02:17 PM
Instead of
if(bodypart == 9 && PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid))
try

if(bodypart == 9 && !IsPlayerAdmin(playerid))

The one who will be logged as rcon admin won't receive headshots.


You can also make a variable for example.
new isGodMode[MAX_PLAYERS];

and set it to 1 when player is in god mode and back to 0 when player leaves god mode.

And then you can check if the player is in god mode instead of checking if he is logged as rcon admin.

crukk11
11/04/2017, 03:14 PM
cannot work

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID && bodypart == 9)
{
if(IsPlayerConnected(issuerid))
{
if(bodypart == 9 || !IsPlayerAdmin(playerid) || god_mode[playerid] == 0)
{
SetPlayerHealth(playerid, 0.0);
new string[100], pname[24];
GetPlayerName(playerid, headshot, sizeof(headshot));
GetPlayerName(issuerid, pname, sizeof(pname));
format(string, sizeof(string), "%s(%i) was shoot to the Head by %s(%i)", headshot,playerid, pname, issuerid);
GivePlayerMoney(issuerid, 100);
SendClientMessageToAll(0x800000AA,string);
GameTextForPlayer(issuerid,"~r~HeadShot",2000,1);
PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid,"~r~HeadShot",2000,1);
ApplyAnimation(playerid, "PED", "ko2", 4.1, 1, 1, 1, 1, 1, 1); // applying the dead guy animation tho you can one your own.
PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0);
}
}
}
return 1;
}

crukk11
11/04/2017, 03:47 PM
help

crukk11
11/04/2017, 05:42 PM
help

Marricio
11/04/2017, 05:48 PM
Change this
if(bodypart == 9 || !IsPlayerAdmin(playerid) || god_mode[playerid] == 0)

to
if(bodypart == 9 && !IsPlayerAdmin(playerid) && !god_mode[playerid])

crukk11
12/04/2017, 03:43 AM
thank it work