CMD:duel(playerid, params[]) { GetPlayerName(playerid, pname, sizeof(pname)); format(stringu, sizeof(stringu), "{54da00}[COMANDO]{ffffff}%s (ID: %d) ha usato il cmd {ff0000}/Duel", pname, playerid); SendClientMessageToAll(COLOR_LIGHTBLUE, stringu); if(IsPlayerConnected(playerid)) { tmp = strtok(params, idx); if(!strlen(tmp)) { SendClientMessage(playerid, Red, "[ERRORE:]{FFFFFF} /duel [ID]"); return 1; } giveplayerid = ReturnUser(tmp); if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { if(statod[playerid] == 1 ) { SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Hai giа sfidato qualcuno"); } if(statod[playerid] == 2 ) { SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Sei giа stato sfidato da qualcuno a un duello"); } if(statod[playerid] == 3 ) { SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Stai giа partecipando a un duello"); } else if(statod[playerid] == 0 ) { if(statod[giveplayerid] == 1 ) { SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Il giocatore ha giа sfidato qualcuno a un duello"); } if(statod[giveplayerid] == 2 ) { SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Il giocatore и giа stato sfidato a un duello"); } if(statod[giveplayerid] == 3 ) { SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Il giocatore sta giа partecipando a un duello"); } else if(statod[giveplayerid] == 0 ) { statod[playerid] = 1; statod[giveplayerid] = 2; GetPlayerName(playerid,nome,sizeof(nome)); GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer)); format(string4,sizeof(string4),"[DUELLO:]{FFFFFF} %s ha sfidato %s a un duello", nome, giveplayer); SendClientMessageToAll(COLOR_ORANGE,string4); format(string4,sizeof(string4),"[DUELLO:]{FFFFFF} Hai sfidato %s a un duello, aspetta una risposta", giveplayer); SendClientMessage(playerid, COLOR_ORANGE,string4); sfidante[giveplayerid] = playerid; format(string4,sizeof(string4),"[DUELLO:]{FFFFFF} Sei stato sfidato da %s a un duello, scrivi /accetta o /rifiuta", nome); SendClientMessage(giveplayerid, COLOR_ORANGE, string4); } } } } } return 1; }
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, Red, "[ERROR:]{FFFFFF} /duel [playerid]");
#include <sscanf2>
i recommend you to use sscanf, it's way better and easier than strtok.
remove all your strtok things from the command and do: pawn Код:
pawn Код:
https://sampforum.blast.hk/showthread.php?tid=120356 the download link of sscanf is also there. |
CMD:duel(playerid, params[])
{
new targetid;
GetPlayerName(playerid, pname, sizeof(pname));
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, Red, "[ERROR:]{FFFFFF} /duel [playerid]");
if(IsPlayerConnected(playerid))
{
tmp = strtok(params, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Red, "[ERRORE:]{FFFFFF} /duel [ID]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(statod[playerid] == 1 )
{
SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Hai giа sfidato qualcuno");
}
if(statod[playerid] == 2 )
{
SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Sei giа stato sfidato da qualcuno a un duello");
}
if(statod[playerid] == 3 )
{
SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Stai giа partecipando a un duello");
}
else if(statod[playerid] == 0 )
{
if(statod[giveplayerid] == 1 )
{
SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Il giocatore ha giа sfidato qualcuno a un duello");
}
if(statod[giveplayerid] == 2 )
{
SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Il giocatore и giа stato sfidato a un duello");
}
if(statod[giveplayerid] == 3 )
{
SendClientMessage(playerid,Red,"[ERRORE:]{FFFFFF} Il giocatore sta giа partecipando a un duello");
}
else if(statod[giveplayerid] == 0 )
{
statod[playerid] = 1;
statod[giveplayerid] = 2;
GetPlayerName(playerid,nome,sizeof(nome));
GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer));
format(string4,sizeof(string4),"[DUELLO:]{FFFFFF} %s ha sfidato %s a un duello", nome, giveplayer);
SendClientMessageToAll(COLOR_ORANGE,string4);
format(string4,sizeof(string4),"[DUELLO:]{FFFFFF} Hai sfidato %s a un duello, aspetta una risposta", giveplayer);
SendClientMessage(playerid, COLOR_ORANGE,string4);
sfidante[giveplayerid] = playerid;
format(string4,sizeof(string4),"[DUELLO:]{FFFFFF} Sei stato sfidato da %s a un duello, scrivi /accetta o /rifiuta", nome);
SendClientMessage(giveplayerid, COLOR_ORANGE, string4);
}
}
}
}
}
return 1;
}
pawn Код:
Place it like this, but you have to edit the other lines too, not just this one.. |