dcmd_move(playerid,params[]) { new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index); if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, POLICE_COLOR, "USAGE: /move [X] [Y] [Z]"); new X, Y, Z, string[128]; return SetPlayerPos(playerid, X, Y, Z); }
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
dcmd_move(playerid,params[])
{
#pragma unused Index
new tmp[256], tmp2[256], tmp3[256], Index;
tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, POLICE_COLOR, "USAGE: /move [X] [Y] [Z]");
new X, Y, Z;
return SetPlayerPos(playerid, X, Y, Z);
}
Originally Posted by hazdog
it gets a perfect compile but just says unknown command in game.
|
//bottom of script
dcmd_move( playerid, params[] )
{
new
Float:x,
Float:y,
Float:z;
if ( sscanf( params, "fff", x, y, z ) ) return SendClientMessage( playerid, POLICE_COLOR, "USAGE: /move [X] [Y] [Z]" );
SetPlayerPos( playerid, x, y, z );
return 1;
}
//OnPlayerCommandText
dcmd(move, 4, cmdtext);
Originally Posted by brett7
it says undefined symbol strtok did you define it right?
pawn Code:
|
strtok(const string[], &index, separator = ' ')
{
new length = strlen(string);
while ((index < length) && (string[index] <= separator))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > separator) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}