CMD:test( playerid, params[] )
{
if( sscanf( params, "s[32]", params[0]) )
return SendClientMessage(playerid, Mainrojo, "Usa: /test [ test , test2 , test3 ] [ test4 ] [ test5 ]");
if(!strcmp( params[0], "test", true))
{
if( sscanf( params, "s[4]s[32]", params[1] , params[2]) )
return SendClientMessage(playerid, Mainrojo, "Usa: /test test [test4] [test5]");
CMD:test( playerid, params[] )
{
if( sscanf( params, "sssss", params[0]) )
return SendClientMessage(playerid, Mainrojo, "Usa: /test [ test , test2 , test3 ] [ test4 ] [ test5 ]");
if(!strcmp( params[0], "test", true))
{
if( sscanf( params, "sss", params[1] , params[2]) )
return SendClientMessage(playerid, Mainrojo, "Usa: /test test [test4] [test5]");
pawn Код:
|
CMD:carro(playerid, params[])
{
new id, cor, cor2, Float:pos[3];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
if(sscanf(params, "iii", id, cor, cor2)) return SendClientMessage(playerid, -1, "[ERRO]: /carro [id] [cor 1] [cor 2");
CreateVehicle(id,pos[0],pos[1],pos[2],0,cor,cor2,-1);
SendClientMessage(playerid, -1, "[INFO]: veiculo criado com sucesso");
return 1;
}
new
mycmd[] = "/test [testeprimeiro,testesegundo,testeterceiro][testequarto][testequinto]",
param[5][20]
;
strdel(mycmd, 0, (strfind(mycmd, "[")) + 1);
format(param[0], 20, getParam(mycmd, 0, ','));
format(param[1], 20, getParam(mycmd, 1, ','));
// ~>Aqui comeзa a putaria.
static
i, l_pos
;
i = 0;
while(mycmd[i] ^ '\0'){
if(mycmd[i] == ',') l_pos = i;
i ++;
}
strdel(mycmd, 0, l_pos + 1);
strmid(param[2], mycmd, 0, strfind(mycmd, "]"));
strdel(mycmd, 0,strfind(mycmd, "]") +2);
strmid(param[3], mycmd, 0, strfind(mycmd, "]"));
strdel(mycmd, 0,strfind(mycmd, "]") +2);
strdel(mycmd, strfind(mycmd, "]"), strlen(mycmd));
format(param[4], 20, mycmd);
// ===============================================
printf("Parвmetro 0 ----> %s", param[0]);
printf("Parвmetro 1 ----> %s", param[1]);
printf("Parвmetro 2 ----> %s", param[2]);
printf("Parвmetro 3 ----> %s", param[3]);
printf("Parвmetro 4 ----> %s", param[4]);
// ==============================================
stock getParam(intstring[], parameter, delim){ // Suyann Dбcio
static
szStringOut[128],
Loop_Interator,
LastWorldSize,
String_Size,
Parameters
;
// Setting:
String_Size = strlen(intstring);
// Resetting:
szStringOut[0] = EOS;
Loop_Interator = 0 ;
LastWorldSize = 0 ;
Parameters = 0 ;
for ( ; Loop_Interator != String_Size; ++Loop_Interator){
if(intstring[Loop_Interator] == delim){
if(Parameters == parameter){
strmid(szStringOut, intstring,(parameter != 0 ? (LastWorldSize + 1) : (LastWorldSize)), Loop_Interator);
break;
}
Parameters ++;
LastWorldSize = Loop_Interator;
}
}
return szStringOut;
}
Sem sscanf ou qualquer processador de comandos:
PHP код:
pawn Код:
|
CMD:editarcarro(playerid, params[])
{
new tipo[25], ID, Model;
if( sscanf( params, "s[25]", tipo))
{
SendClientMessage (playerid, -1, "USO: /editarcarro <parte do carro>");
SendClientMessage (playerid, -1, "Partes validas: modelo, cor");
return 1;
}
if(strcmp(tipo, "modelo", true) == 0)
{
if( sscanf( params, "{s[25]}ii", ID, Model ) )
{
SendClientMessage (playerid, -1, "USO: /editarcarro <parte do carro> <id do carro> <modelo>");
return 1;
}
// Continua....
}
if(strcmp(tipo, "cor", true) == 0)
{
// Continua....
}
return 1;
}