Not really a hard question but still try to help me -
Mean - 11.09.2010
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);
Re: Not really a hard question but still try to help me -
LarzI - 11.09.2010
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!" );
}
Re: Not really a hard question but still try to help me -
Mean - 11.09.2010
Well, i tried ZCMD but i get some errors so i use STRCMP, anyways lemme see if this works
Re: Not really a hard question but still try to help me -
Mean - 11.09.2010
0.0 lol, when i type /heal [ID] my server crashes and i loose connection, RCON shuts down lol
Re: Not really a hard question but still try to help me -
LarzI - 11.09.2010
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
Re: Not really a hard question but still try to help me -
Mean - 12.09.2010
Do you may have dcmd version?
Re: Not really a hard question but still try to help me -
LarzI - 12.09.2010
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]))))
Re: Not really a hard question but still try to help me -
Mean - 12.09.2010
thanks dude
with a few touches of my own works perfectly
