Problemas al pasar comandos de strcmp a cmd -
Jeree10 - 01.10.2014
Hola intente pasar este comando a cmd:
Dejo el original y el mio
Original
pawn Код:
if(strcmp(cmd, "/y", true) == 0 || strcmp(cmd, "/me", true) == 0){
if(IsPlayerConnected(playerid)){
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' ')){
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))){
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)){
SendClientMessage(playerid, COLOR_YELLOW, "/y [accion]");
return 1;
}
new jugador[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, jugador, sizeof(jugador));
if(PlayerInfo[playerid][IUSER] >= 0){
format(string, sizeof(string), "* %s %s", jugador, result);
}
ProxDetector(30.0, playerid, string, Rol,Rol,Rol,Rol,Rol);
printf("%s", string);
}
return 1;
}
Pasado
pawn Код:
CMD:y(playerid, params[])return cmd_me(playerid, params);
CMD:me(playerid, params[])
{
if(IsPlayerConnected(playerid)){
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' ')){
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))){
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)){
SendClientMessage(playerid, COLOR_YELLOW, "/y [accion]");
return 1;
}
new jugador[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, jugador, sizeof(jugador));
if(PlayerInfo[playerid][IUSER] >= 0){
format(string, sizeof(string), "* %s %s", jugador, result);
}
ProxDetector(30.0, playerid, string, Rol,Rol,Rol,Rol,Rol);
printf("%s", string);
}
return 1;
}
Errores:
Код:
C:\Users\AsusEvo\Desktop\GM_Base\gamemodes\Mio.pwn(1198) : error 017: undefined symbol "cmdtext"
C:\Users\AsusEvo\Desktop\GM_Base\gamemodes\Mio.pwn(1199) : error 017: undefined symbol "idx"
C:\Users\AsusEvo\Desktop\GM_Base\gamemodes\Mio.pwn(1199) : error 029: invalid expression, assumed zero
C:\Users\AsusEvo\Desktop\GM_Base\gamemodes\Mio.pwn(1199) : error 029: invalid expression, assumed zero
C:\Users\AsusEvo\Desktop\GM_Base\gamemodes\Mio.pwn(1199) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
Linea 1198:
pawn Код:
new length = strlen(cmdtext);
1199:
pawn Код:
while ((idx < length) && (cmdtext[idx] <= ' ')){
Respuesta: Problemas al pasar comandos de strcmp a cmd -
Su37Erich - 01.10.2014
No estб definido cmdtext, por eso te salta el error, como veo que usas comandos con argumentos, te recomiendo usar sscanf en lugar del la funciуn que estas utilizando:
pawn Код:
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' ')){
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))){
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)){
SendClientMessage(playerid, COLOR_YELLOW, "/y [accion]");
return 1;
}
Con sscanf irнa asн:
pawn Код:
new accion;
if(sscanf(params, "d", accion))
return SendClientMessage(playerid, COLOR_YELLOW, "/y [accion]");
Acб la pбgina para que lo descargues y veas mas informaciуn:
https://sampforum.blast.hk/showthread.php?tid=120356