SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 18/01/2011, 02:07 PM   #1
Larsey123IsMe
Guest
 
Posts: n/a
Default [QUESTION/HELP] DCMD Question

if someone type:
"/healme 2"
"/healme LoL"
or something with "/healme(SPACE)(RANDOM NUMBER/TEXT)"
then this should return "SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");"
is that possible? Yes, i guess xD but how O.o

pawn Code:
dcmd_healme(playerid, params[])
{
    if(sscanf(params, "s", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");
    else
    {
        SetPlayerHealth(playerid, 100.0);
        SendClientMessage(playerid, 0x00FF00AA, "You have been healed");
        return 1;
    }
}
 
Old 18/01/2011, 02:11 PM   #2
Not available
Big Clucker
 
Join Date: Jan 2011
Posts: 94
Reputation: 0
Default Re: [QUESTION/HELP] DCMD Question

What do you mean? Could this work.
pawn Code:
if(sscanf(params, " s", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");
__________________


http://peak-host.net Your #1 Multi-player Game hosting provider.
Not available is offline  
Old 18/01/2011, 02:11 PM   #3
damiantof7
Big Clucker
 
damiantof7's Avatar
 
Join Date: Apr 2010
Location: Oldenzaal, Netherlands
Posts: 66
Reputation: 0
Default Re: [QUESTION/HELP] DCMD Question

You mean something like this?

pawn Code:
dcmd_heal(playerid, params[])
{
        new id;
    if (strlen(params))
    {
        id = strval(params);
        if (IsPlayerConnected(id))
        {
            SetPlayerHealth(id, 100.0);
            SendClientMessage(id, 0x00FF00AA, "You have been healed");
            SendClientMessage(playerid, 0x00FF00AA, "Player healed");
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
    }
    return 1;
}
damiantof7 is offline  
Old 18/01/2011, 02:13 PM   #4
damiantof7
Big Clucker
 
damiantof7's Avatar
 
Join Date: Apr 2010
Location: Oldenzaal, Netherlands
Posts: 66
Reputation: 0
Default Re: [QUESTION/HELP] DCMD Question

But then for yourself?
damiantof7 is offline  
Old 18/01/2011, 02:13 PM   #5
iggy1
High-roller
 
iggy1's Avatar
 
Join Date: Mar 2009
Location: One past the end.
Posts: 2,421
Reputation: 273
Default Re: [QUESTION/HELP] DCMD Question

pawn Code:
dcmd_healme(playerid, params[])
{
    new
        id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");
    else
    {
        SetPlayerHealth(id, 100.0);
        SendClientMessage(id, 0x00FF00AA, "You have been healed");
        return 1;
    }
}
If i understood correct that should do it.

EDIT: Just realised its a healme cmd and not healplayer durr.

Last edited by iggy1; 18/01/2011 at 02:28 PM. Reason: Fixed code
iggy1 is offline  
Old 18/01/2011, 02:15 PM   #6
xir
Gangsta
 
Join Date: Aug 2010
Posts: 746
Reputation: 3
Default Re: [QUESTION/HELP] DCMD Question

I think you need to change this line
pawn Code:
if(sscanf(params, "s", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");

to
pawn Code:
if(sscanf(params, "u", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");
xir is offline  
Old 18/01/2011, 02:18 PM   #7
Alex_Valde
Huge Clucker
 
Alex_Valde's Avatar
 
Join Date: Mar 2010
Location: Croatia
Posts: 342
Reputation: 4
Default Re: [QUESTION/HELP] DCMD Question

Or this:
pawn Code:
cmd_healme(playerid, params[])
{
    if(isnull(params))
    {
        SetPlayerHealth(playerid, 100.0);
        SendClientMessage(playerid, 0x00FF00AA, "You have been healed");
    }
    else return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");//if he adds ANYTHING after healme this will come up.
    return 1;
}
Alex_Valde is offline  
Old 18/01/2011, 02:23 PM   #8
alpha500delta
High-roller
 
alpha500delta's Avatar
 
Join Date: Feb 2010
Posts: 1,152
Reputation: 91
Default Re: [QUESTION/HELP] DCMD Question

Quote:
Originally Posted by xir View Post
I think you need to change this line
pawn Code:
if(sscanf(params, "s", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");

to
pawn Code:
if(sscanf(params, "u", playerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");
Thats wrong. U needs to be id
and he needs to put new id;
__________________
Skype: Alpha500delta | Steam: Alpha500delta
alpha500delta is offline  
Old 18/01/2011, 02:36 PM   #9
Larsey123IsMe
Guest
 
Posts: n/a
Default Re: [QUESTION/HELP] DCMD Question

Quote:
Originally Posted by alpha500delta View Post
Thats wrong. U needs to be id
and he needs to put new id;
Correct! but.. still...

i dont mean a "/healme <playerid>" command
i mean "/healme" and if he type like "/healme (random things)"
then return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");

pawn Code:
and.. How to:
If the number is more than 100 and less than 1 then this should return:
"SendClientMessage(playerid, 0xFF0000FF, "ERRROR: Max: 100 Minimum: 1);"

Example: "
/heal 1 1000"
1000 = Over the maximum (100) so then the Message (SendClientMessage(playerid, 0xFF0000FF, "
ERRROR: Max: 100 Minimum: 1);) shuld return...

Something Like:
else if(amount <= 1 && amount >= 100) return SendClientMessage(playerid, 0xFF0000FF, "ERRROR: Max: 100 Minimum: 1");

Sorry for bad english, GRRRR
 
Old 18/01/2011, 02:47 PM   #10
Alex_Valde
Huge Clucker
 
Alex_Valde's Avatar
 
Join Date: Mar 2010
Location: Croatia
Posts: 342
Reputation: 4
Default Re: [QUESTION/HELP] DCMD Question

I made it quickly so just try it. Should work perfectly though.

pawn Code:
cmd_healme(playerid, params[])
{
    new pID, pHealth;
    if(!sscanf(params, "ui",pID, pHealth))
    {
        if(IsPlayerConnected(pID))
        {
            if(pHealth > 1 || pHealth < 101)
            {
                SetPlayerHealth(pID, pHealth);
                SendClientMessage(pID, 0x00FF00AA, "You have been healed");
            }
            else return SendClientMessage(playerid, 0xFFFFFFFF,"Error: Please use |Max|: 100, |Min|: 1");
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF,"This player is not online.");
         
    }
    else return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/healme\"");//if he adds ANYTHING after healme this will come up.
    return 1;
}

Not tested!
Alex_Valde is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dcmd question. oliverrud Help Archive 4 06/07/2010 12:13 PM
dcmd question. _CHoz Help Archive 4 13/10/2009 08:03 PM
Question about dcmd ans sscanf Outbreak Help Archive 14 28/08/2009 10:53 AM
DCMD question BSMan Help Archive 6 19/06/2009 03:08 PM


All times are GMT. The time now is 11:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.