[QUESTION/HELP] DCMD Question
#20

Your coding syntax is a little strange. Those brackets for example after the else if check do absolutely nothing except make it look pretty, they aren't part of any statement. Here is how I would code it:

pawn Code:
dcmd_setplayerhealth(playerid, params[])
{
    new targetid, Float:amount;

    if(sscanf(params, "uf", targetid, amount)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/setplayerhealth <playerid> <amount>\"");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    if(amount > 1 && amount < 101)
    {
        new playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], string[256];
        GetPlayerName(playerid, playername, sizeof(playername));
        GetPlayerName(targetid, targetname, sizeof(targetname));

        format(string, sizeof(string), "%s(%d) set %s(%d)'s health to %.0f", targetname, targetid, playername, playerid, amount);
        SendClientMessageToAll(0x50FF05FF, string);

        SetPlayerHealth(playerid, amount);
    }
    else SendClientMessage(playerid, 0xFFFFFFFF,"Error: Please use |Max|: 100, |Min|: 1");
    return 1;
}
Reply


Messages In This Thread
[QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 14:07
Re: [QUESTION/HELP] DCMD Question - by Not available - 18.01.2011, 14:11
Re: [QUESTION/HELP] DCMD Question - by damiantof7 - 18.01.2011, 14:11
Re: [QUESTION/HELP] DCMD Question - by damiantof7 - 18.01.2011, 14:13
Re: [QUESTION/HELP] DCMD Question - by iggy1 - 18.01.2011, 14:13
Re: [QUESTION/HELP] DCMD Question - by xir - 18.01.2011, 14:15
Re: [QUESTION/HELP] DCMD Question - by Alex_Valde - 18.01.2011, 14:18
Re: [QUESTION/HELP] DCMD Question - by alpha500delta - 18.01.2011, 14:23
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 14:36
Re: [QUESTION/HELP] DCMD Question - by Alex_Valde - 18.01.2011, 14:47
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 15:03
Re: [QUESTION/HELP] DCMD Question - by alpha500delta - 18.01.2011, 15:07
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 15:09
Re: [QUESTION/HELP] DCMD Question - by JaTochNietDan - 18.01.2011, 15:14
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 15:27
Re: [QUESTION/HELP] DCMD Question - by Alex_Valde - 18.01.2011, 15:30
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 15:33
Re: [QUESTION/HELP] DCMD Question - by Alex_Valde - 18.01.2011, 15:37
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 15:47
Re: [QUESTION/HELP] DCMD Question - by JaTochNietDan - 18.01.2011, 15:49
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 15:53
Re: [QUESTION/HELP] DCMD Question - by Alex_Valde - 18.01.2011, 15:55
Re: [QUESTION/HELP] DCMD Question - by JaTochNietDan - 18.01.2011, 15:57
Re: [QUESTION/HELP] DCMD Question - by Larsey123IsMe - 18.01.2011, 16:30

Forum Jump:


Users browsing this thread: 8 Guest(s)