08.02.2011, 00:36
how do i set a Variable with strtok
public OnPlayerCommandText(playerid, cmdtext[]){
new index,giveplayerid;
new cmd[256],tmp[256];
cmd = strtok(cmdtext, index);
if (strcmp("/stats", cmd, true, 10) == 0) {
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) { //if nothing was typed after the command send help
SendClientMessage(playerid,COLOUR_WHITE,"Usage:/stats 'ID'");
return 1;
}
giveplayerid = strval(tmp);//a playerid is a number so we conver the string to a number
if(!IsPlayerConnected(giveplayerid)) {//is the requested player connected
SendClientMessage(playerid,COLOUR_BAD,"Invalid ID");
return 1;
}
else {
// show stats
printf("stats for playid %d",giveplayerid); //info to console
return 1;
}
}
return 0;
}