[HELP]HEAL COMMAND - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]HEAL COMMAND (
/showthread.php?tid=235336)
[HELP]HEAL COMMAND -
[Aka]Dragonu - 05.03.2011
Hi. I made a heal command but it heals only me even if i tipe /aheal 3 and i have id 3 online still i get healed and he doesn't. Here is my code :
pawn Код:
if(strcmp(cmd, "/aheal", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /aheal [playerid]");
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
// GetPlayerName(playerid, sendername, sizeof(sendername));
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 102)
{
new Float:tempheal;
GetPlayerHealth(giveplayerid,tempheal);
SetPlayerHealth(giveplayerid, 100);
SetPlayerArmour(playerid,100);
PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
{
format(string, sizeof(string), "Server : %s Has been healed by admin %s.", PlayerName[giveplayerid], PlayerName[playerid]);
SendClientMessageToAll(COLOR_RED, string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command !");
return 1;
}
}
}
else
{
format(string, sizeof(string), "That player is offline.", giveplayerid);
SendClientMessage(playerid, COLOR_GREY, string);
}
}
return 1;
}
Re: [HELP]HEAL COMMAND -
[Aka]Dragonu - 06.03.2011
bump topic
Re: [HELP]HEAL COMMAND -
[WF]Demon - 06.03.2011
pawn Код:
COMMAND:aheal(playerid, params[])
{
new otherid;
if(sscanf(params, "i", otherid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /aheal [ID]");
if(!IsPlayerConnected(otherid)) return SendClientMessage(playerid, COLOR_GREY, "That Player Is Not Connected!");
SetPlayerHealth(otherid, 100);
return 1;
}
^^ Sped up, More efficient And SO MUCH EASIER.
I suggest ZCMD and SSCANF all the way, strtok Gives me a headache.
Re: [HELP]HEAL COMMAND -
[Aka]Dragonu - 06.03.2011
No, I want my command to remain the same but to solve only my problem !
Re: [HELP]HEAL COMMAND - rjjj - 06.03.2011
I did it
pawn Код:
if(strcmp(cmd, "/aheal", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /aheal [playerid]");
return 1;
}
if(IsPlayerConnected(strval(tmp))
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 102)
{
SetPlayerHealth(strval(tmp), 100.0);
SetPlayerArmour(strval(tmp),100.0);
PlayerPlaySound(strval(tmp), 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "Server : %s Has been healed by admin %s.", PlayerName[strval(tmp)], PlayerName[playerid]);
SendClientMessageToAll(COLOR_RED, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command !");
return 1;
}
}
else
{
format(string, sizeof(string), "That player is offline.", giveplayerid);
SendClientMessage(playerid, COLOR_GREY, string);
}
}
return 1;
}
I hope that i have helped
Re: [HELP]HEAL COMMAND -
omer5198 - 06.03.2011
try this... (it should work... i tried this on my gamemode and works perfectly!!!
pawn Код:
if(strcmp(cmd, "/aheal", true) == 0){
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, COLOUR_ORANGE, "Usage: /aheal [playerid]");
return 1;
}
new victim;
victim = strval(tmp);
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
new playername2[MAX_PLAYER_NAME];
new string[128];
GetPlayerName(victim, playername2, sizeof(playername2));
if(!IsPlayerConnected(victim) && (victim != INVALID_PLAYER_ID)){
if((IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 102)){
format(string, sizeof(string), "The admin %s healed %s.", playername, playername2);
SendClientMessageToAll(COLOUR_RED, string);
SetPlayerHealth(victim, 100);
}
else{
SendClientMessage(playerid, COLOUR_RED, "You must be an admin to use this command!");
return 1;
}
}
else{
SendClientMessage(playerid, COLOUR_RED, "this player is not connected");
}
return 1;
}