SA-MP Forums Archive
[Tutorial] Basic Commands 1 (ZCMD)- /explode, /gethp - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Basic Commands 1 (ZCMD)- /explode, /gethp (/showthread.php?tid=370288)



Basic Commands 1 (ZCMD)- /explode, /gethp - SKAzini - 19.08.2012

/explode

pawn Code:
CMD:explode(playerid, params[])
{
    new string[128], ID, Float:x, Float:y, Float:z; //Define ID (the playerid you are going to explode) and the floats where the explosion shall be created (ID's position).
    if(sscanf(params, "u", ID)) SendClientMessage(playerid, -1, "Correct usage: /explode <playerid/name>"); //Show a message with correct usage of the command, if inputted wrong.
    else if(!IsPlayerConnected(ID)) SendClientMessage(playerid, -1, "That player is not online."); //Output if ID is not online.
    else //If everything has gone fine, do this.
    {
        GetPlayerPos(ID, x, y, z); //Get ID's pos and store the pos in the floats x, y, z.
        CreateExplosion(x, y, z, 12, 10.0); //Create an explosion at the pos retrieved from x, y, z.
        format(string,sizeof(string), "You have exploded %s(%d).", PlayerName(ID), ID); //Store neat message showing that you've exploded "IDsName(ID)", eg. Barry(16) in string.
        SendClientMessage(playerid, -1, string); //Output the string to the client.
    }
}
/gethp
Usefull with the /explode command, checking if a player is using health hack.

pawn Code:
CMD:gethp(playerid, params[])
{
    new string[128], ID, Float:health; //Define string, ID & health float.
    if(sscanf(params, "u", ID)) SendClientMessage(playerid, -1, "Correct usage: /gethp <playerid/name>"); //Show a message with correct usage of the command, if inputted wrong.
    else if(!IsPlayerConnected(ID)) SendClientMessage(playerid, -1, "That player is not online."); //Output if ID is not online.
    else //If everything has gone fine, do this.
    {
        GetPlayerHealth(ID, health); //Store health in health float.
        format(string,sizeof(string), "%s(%d)'s health level is %f.", PlayerName(ID), ID, health); //String to store the output (Health will output as eg. 100.0000, as it is a float)
        SendClientMessage(playerid, -1, string); //Output string to the client.
    }
}
More will be added in the future.