14.07.2011, 14:27
I don't know if that's what you mean, but tell me anyways.
USE strtok, if you have knowledge with zcmd and sscanf then you better convert it, much better.
Hope that's what you needed..
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new
cmd[256], tmp[256], string[128], idx,
o_name[MAX_LAYER_NAME], p_name[MAX_PLAYER_NAME]
;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/dlicense", true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /dlicense [ID]");
new id = strval(tmp);
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "SERVER: playerid is not connected");
GetPlayerName(id, o_name, sizeof(o_name));
GetPlayerName(playerid, p_name, sizeof(p_name));
format(string, sizeof(string), "CarLicenses/%s.ini", o_name);
if(!fexist(string)) {
format(string, sizeof(string), "%s his license, NOT PASSED.", p_name);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You have showed your license to %s.", o_name);
SendClientMessage(playerid, -1, string);
} else {
format(string, sizeof(string), "%s his license, PASSED.", p_name);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "You have showed your license to %s.", o_name);
SendClientMessage(playerid, -1, string);
}
printf("LICENSE: [%d]%s showed [%d]%s his license.", playerid, p_name, id, o_name);
return 1;
}
return 0;
}
pawn Код:
stock 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;
}