Not really a hard question but still try to help me
#1

How to make a command which has [ID] in it, like /heal [ID], usually it would just heal you because of playerid code, is there anything like this:
pawn Код:
SetPlayerHealth(idyoupicked, 100);
Reply
#2

strcmp:

pawn Код:
if( !strcmp( cmdtext, "/heal", true ))
{
    new
        ID = strval( cmdtext[ 6 ]);
    if( cmdtext[ 6 ] = '\0' || ( cmdtext[ 6 ] == '\1' && cmdtext[ 7 ] == '\0' ))
        return SendClientMessage( playerid, 0xFF0000FF, "USAGE: /heal [id]" );
    if( !IsPlayerConnected( ID ))
        return SendClientMessage( playerid, 0xFF0000FF, "Invalid ID");
    SetPlayerHealth( ID, 100 );
    return SendClientMessage( playerid, 0x00FF00FF, "Player healed!" );
}
>this one's recommended to use:<
zcmd+sscanf:

pawn Код:
CMD:heal(playerid, params[])
{
    new
        ID;
    if( sscanf( params, "u", ID ))
        return SendClientMessage( playerid, 0xFF0000FF, "USAGE: /heal [id]" );
    if( !IsPlayerConnected( ID ))
        return SendClientMessage( playerid, 0xFF0000FF, "Invalid ID");
    SetPlayerHealth( ID, 100 ));
    return SendClientMessage( playerid, 0x00FF00FF, "Player healed!" );
}
Reply
#3

Well, i tried ZCMD but i get some errors so i use STRCMP, anyways lemme see if this works
Reply
#4

0.0 lol, when i type /heal [ID] my server crashes and i loose connection, RCON shuts down lol
Reply
#5

pawn Код:
if( !strcmp( cmdtext, "/heal", true ))
{
    if( strlen( cmdtext ) < 6 ))
        return SendClientMessage( playerid, 0xFF0000FF, "USAGE: /heal [id]" );
    new
        ID = strval( cmdtext[ 6 ] );
    if( !IsPlayerConnected( ID ))
        return SendClientMessage( playerid, 0xFF0000FF, "Invalid ID");
    SetPlayerHealth( ID, 100 );
    return SendClientMessage( playerid, 0x00FF00FF, "Player healed!" );
}
Try now
Reply
#6

Do you may have dcmd version?
Reply
#7

pawn Код:
dcmd_heal(playerid, params[])
{
    if( isnull( params ))
        return SendClientMessage( playerid, 0xFF0000FF, "USAGE: /heal [id]" );
    new
        ID = strval( params );
    if( !IsPlayerConnected( ID ))
        return SendClientMessage( playerid, 0xFF0000FF, "Invalid ID");
    SetPlayerHealth( ID, 100 );
    return SendClientMessage( playerid, 0x00FF00FF, "Player healed!" );
}

EDIT: isnull if you don't have it:
pawn Код:
#define isnull(%1) \
((!(%1[0])) || (((%1[0] == '\1') && (!(%1[1]))))
Reply
#8

thanks dude
with a few touches of my own works perfectly

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)