Existem alguns tutorias ensinado a usar a callback OnPlayerCommandText, mas recomendo usar OnPlayerCommandPerformed.
Um exemplo de "conversгo":
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256+1];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/player2v", true) == 0)
{
new tmp[256];
new tmp2[256];
tmp = strtok(cmdtext,idx);
tmp2 = strtok(cmdtext,idx);
PutPlayerInVehicle(strval(tmp),strval(tmp2),0);
return 1;
}
if(strcmp( cmd, "/vc", true ) == 0 )
{
new tmp[256];
new created_vehicle_id;
tmp = strtok( cmdtext, idx );
created_vehicle_id = SpawnVehicle_InfrontOfPlayer(playerid, strval(tmp), -1, -1);
new msg[128+1];
format(msg,128,"Created vehicle: %d",created_vehicle_id);
SendClientMessage(playerid,0xAAAAAAAA,msg);
return 1;
}
return SendClientMessage(playerid, -1, "O comando nгo foi encontrado.");
}
Ficando:
PHP код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success){
//retorna a 1 caso o comando jб tenha sido executado
if(success){
return 1;
}
new cmd[256+1];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/player2v", true) == 0)
{
new tmp[256];
new tmp2[256];
tmp = strtok(cmdtext,idx);
tmp2 = strtok(cmdtext,idx);
PutPlayerInVehicle(strval(tmp),strval(tmp2),0);
return 1;
}
if(strcmp( cmd, "/vc", true ) == 0 )
{
new tmp[256];
new created_vehicle_id;
tmp = strtok( cmdtext, idx );
created_vehicle_id = SpawnVehicle_InfrontOfPlayer(playerid, strval(tmp), -1, -1);
new msg[128+1];
format(msg,128,"Created vehicle: %d",created_vehicle_id);
SendClientMessage(playerid,0xAAAAAAAA,msg);
return 1;
}
return SendClientMessage(playerid, -1, "O comando nгo foi encontrado.");
}
Alguns links que tu pode olhar:
https://sampforum.blast.hk/showthread.php?tid=353756
https://sampforum.blast.hk/showthread.php?tid=619154
Como eu jб disse, o recomendado й refazer todos os comando usando um processados como o zcmd e sscanf.