[Tutorial] Basic Commands 1 (ZCMD)- /explode, /gethp
#1

/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.
Reply


Messages In This Thread
Basic Commands 1 (ZCMD)- /explode, /gethp - by SKAzini - 19.08.2012, 17:27

Forum Jump:


Users browsing this thread: 1 Guest(s)