Problema con un comando
#1

Hola, bueno.. soy inexperto en esto del scripteo, hace tiempo atrбs intentй empezar.. pero no tuve el tiempo ni las ganas.. bueno, irй al grano.. tengo un problema con mi gm, intentй agregar un comando, al ponerlo y todo se me complicу bastante:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
	new cmd[256];

	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/comando", true) == 0) {
    	return 1;
 }
 
SetPlayerHealth(playerid, 0.0);

SendClientMessage(playerid, COLOR_GRIS, "ESTO ES UNA PRUEBA");
return 1;
}
El problema es que el comando deberнa funcionar con /comando, y al ponerlo en el gm no funciona, pero al poner /coman si funciona, ya que el comando hace que el sujeto muera, lo que ocurriу es que morн y me tirу el mensaje que me debнa, entonces el problema es que le quitу los 2 ъltimos caracteres, їCуmo puedo solucionar eso?

Ah!, y tengo otra duda, їCуmo podrнa definir de forma correcta? Es que he probado en cambiarlo y a veces sale "undefined cmd", o algo asн, y realmente me gustarнa saber como definir bien, de forma correcta, y que lo expliquen para mн, ya que se complica.

(Lo que se es que se no se define los comandos con #define, es con #new o creo yo, pero no me funciona tampoco).

GRACIAS.
Reply
#2

pawn Код:
if(strcmp(cmd, "/comando", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
SendClientMessage(playerid, COLOR_GRIS, "ESTO ES UNA PRUEBA");
return 1;
}
Reply
#3

Quote:
Originally Posted by CharlieBrown
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/comando", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
SendClientMessage(playerid, COLOR_GRIS, "ESTO ES UNA PRUEBA");
return 1;
}
Me tira los siguientes errores:

Код:
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(35) : error 017: undefined symbol "strtok"
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(35) : error 033: array must be indexed (variable "cmd")
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(41) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(45) : error 029: invalid expression, assumed zero
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(45) : error 004: function "OnPlayerSpawn" is not implemented
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(49) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(52) : warning 225: unreachable code
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(52) : error 029: invalid expression, assumed zero
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(52) : error 004: function "OnPlayerDeath" is not implemented
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(54) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(57) : warning 225: unreachable code
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(57) : error 017: undefined symbol "SetupPlayerForClassSelection"
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(66) : error 029: invalid expression, assumed zero
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(66) : error 004: function "OnPlayerRequestClass" is not implemented
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(68) : error 017: undefined symbol "SetupPlayerForClassSelection"
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(69) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(72) : warning 225: unreachable code
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(72) : error 029: invalid expression, assumed zero
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/comando", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
SendClientMessage(playerid, COLOR_GRIS, "ESTO ES UNA PRUEBA");
return 1;
}
Reply
#5

Quote:
Originally Posted by CharlieBrown
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/comando", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
SendClientMessage(playerid, COLOR_GRIS, "ESTO ES UNA PRUEBA");
return 1;
}
Ahora me tira estos errores:

Код:
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(32) : error 017: undefined symbol "cmd"
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(36) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(39) : error 029: invalid expression, assumed zero
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(39) : error 004: function "OnPlayerSpawn" is not implemented
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(43) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(46) : warning 225: unreachable code
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(46) : error 029: invalid expression, assumed zero
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(46) : error 004: function "OnPlayerDeath" is not implemented
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(48) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(51) : warning 225: unreachable code
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(51) : error 017: undefined symbol "SetupPlayerForClassSelection"
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(60) : error 029: invalid expression, assumed zero
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(60) : error 004: function "OnPlayerRequestClass" is not implemented
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(62) : error 017: undefined symbol "SetupPlayerForClassSelection"
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(63) : error 079: inconsistent return types (array & non-array)
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(66) : warning 225: unreachable code
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(66) : error 029: invalid expression, assumed zero
D:\Archivos\Simon\Server samp\gamemodes\bare.pwn(66) : error 004: function "OnGameModeInit" is not implemented
Aъn no se soluciona el problema al compilar.
Reply
#6

Use ZCMD
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
     return 1;
}
e no fim do gamemode
pawn Код:
CMD:comando(playerid, params[])
{
SetPlayerHealth(playerid, 0.0);
SendClientMessage(playerid, COLOR_GRIS, "ESTO ES UNA PRUEBA");
return 1;
}
й melhor
OBS: Baixa essa include https://sampforum.blast.hk/showthread.php?tid=91354
e no topo do gamemode
#include zcmd
Reply
#7

Dйjenlo, ya se solucionу.. cierren o lo que sea, el problema ya lo encontrй, es que todo el texto de "SetPlayerHealth" debнa ir adentro { y }, y yo lo puse debajo de eso, entonces eso hacнa que al poner CUALQUIER comando (aunque ni existieran) me tirara ese mensaje ("ESTO ES UN PRUEBA") y me matara, SOLUCIONADO.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)