Converting 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)
+--- Thread: Converting command (
/showthread.php?tid=318626)
Converting command -
John Rockie - 15.02.2012
Hello guys, is anyone able to help me convert this zcmd to strcmd
pawn Код:
CMD:heal(playerid, params[])
{
if(gPlayerClass[playerid] == MEDIC_CLASS)
{
new Float:health, user, Float:x, Float:y, Float:z;
if (sscanf(params, "i", user)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /heal [playerid]");
GetPlayerPos(user, x, y, z); GetPlayerHealth(user, health);
if (!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) return SendClientMessage(playerid, COLOR_WHITE, "You Are Not Close Enough To The Player!");
if (health < 1) return SendClientMessage(playerid, COLOR_WHITE, "Player's Health Is Above 1, And Cannot Be Healed!");
SendClientMessage(playerid, COLOR_WHITE, "You have just been healed!");
SetPlayerHealth(playerid, health + 50);
}
else return SendClientMessage(playerid,COLOR_WHITE,"You Are Not An Medic!");
return 1;
Re: Converting command -
John Rockie - 18.02.2012
Anyone?
Re: Converting command -
Vince - 18.02.2012
No. Just no. You're better of converting all your commands to ZCMD than the other way round.
Re: Converting command -
Twisted_Insane - 18.02.2012
Hell, what do you want with strcmp? (not strcmd)
ZCMD is the fastest command-processor and is the easiest, best way to write your CMDs! I swear if anybody'll convert this for him into strcmp, I'll report that user! -_-
Re: Converting command -
Guitar - 18.02.2012
I've re-wrote the command, I hope it works:
pawn Код:
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
if(gPlayerClass[playerid] == MEDIC_CLASS)
{
new Float:health, user, Float:x, Float:y, Float:z;
if(sscanf(cmdtext, "i", user)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /heal [playerid]");
GetPlayerPos(user, x,y,z); GetPlayerHealth(user, health);
if(!IsPlayerInRangeOfPoint(playerid, 5, x,y,z)) return SendClientMessage(playerid, COLOR_WHITE, "You aren't close enough to the player.");
if(health < 1) return SendClientMessage(playerid, COLOR_WHITE, "[Error]: The health of the player is above 1..");
SendClientMessage(playerid, COLOR_WHITE, "You've been healed.");
SetPlayerHealth(playerid, health + 50);
}
else return SendClientMessage(playerid, COLOR_WHITE, "You aren't a medic.");
return 1;
}