10.01.2019, 19:09
Im trying to write a little command with multi-parameters for a server.
The first code that i wrote it was this
(Is Im Italian)
But didn't work, for example when the admin try the command:
"/admin give soldi [id] [ammount]"
the command didn't work, the console show only this string
"sscanf warning: Strings without a length are deprecated, please add a destination size."
how i can fix it? or if someone can write a similar command? This is for admin, and i need to create for other player that aren't admins, for example in the RP server for putting or takeing something in the hood of the car.
The first code that i wrote it was this
Код:
COMMAND:admin(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new
option[128],
item[128],
TargetPlayer,
TargetPlayerName [ MAX_PLAYER_NAME ],
AmmountP,
AdminName [ MAX_PLAYER_NAME ],
command[128];
new szStr[ 128 ];
GetPlayerName( playerid, AdminName, MAX_PLAYER_NAME );
GetPlayerName( TargetPlayer, TargetPlayerName, MAX_PLAYER_NAME );
sscanf(params, "sss", option, item, command, TargetPlayer, AmmountP);
if (isnull(option))
{
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /admin [Opzione]");
SendClientMessage(playerid, COLOR_WHITE, " OPTIONS: Give | Sett | SelfSETT");
return 1;
}
if (!strcmp(item, "Give") || !strcmp(item, "give"))
{
if (isnull(item))
{
SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Usa /admin Give [Ozione]");
SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[USI]: soldi | armatura | vita");
return 1;
}
if (!strcmp(item, "Soldi") || !strcmp(item, "soldi"))
{
if(sscanf(command, "ui", TargetPlayer, AmmountP)) return SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Usa /admin give soldi [ID/nome giocatore] [Quantitа]");
if(!IsPlayerConnected(TargetPlayer)) return SendClientMessage(playerid, COLOR_SYSTEM_ERROR,"[ERRORE]: Il giocatore selezionato non и connesso o id/nome sbagliato");
GivePlayerMoney(TargetPlayer, AmmountP);
// Messaggio di avviso
format( szStr, sizeof(szStr), "[ADMIN]: %s ti ha givvato %i$", AdminName, AmmountP );
SendClientMessage(TargetPlayer, COLOR_SYSTEM_INFO, szStr );
format( szStr, sizeof(szStr), "[INFO]: Hai givvato a %s %i$", TargetPlayerName, AmmountP );
SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, szStr );
return 1;
}
else if (!strcmp(item, "Armatura") || !strcmp(item, "armatura"))
{
if(sscanf(command, "u", TargetPlayer)) return SendClientMessage(playerid, 0xFFFFFFF,"Syntax error.Correct usage: /givesoldi [PlayerID] [Soldi]");
if(!IsPlayerConnected(TargetPlayer)) return SendClientMessage(playerid, 0xFFFFFFF,"That player is not connected to the server!");
SetPlayerArmour(TargetPlayer, 100);
return 1;
}
else if (!strcmp(item, "money"))
{
// Code for the money...
}
}
else if (!strcmp(option, "Sett") || !strcmp(option, "sett"))
{
if (isnull(item))
{
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /admin sett [Opzione]");
SendClientMessage(playerid, COLOR_WHITE, " OPTIONS: armatura, vita, Money");
return 1;
}
else if (!strcmp(item, "Armatura") || !strcmp(item, "armatura"))
{
if(sscanf(command, "u", TargetPlayer)) return SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Usa /admin sett armatura [ID/nome giocatore]");
if(!IsPlayerConnected(TargetPlayer)) return SendClientMessage(playerid, COLOR_SYSTEM_ERROR,"[ERRORE]: Il giocatore selezionato non и connesso o id/nome sbagliato");
// Setting dell'armatura al giocatore selezionato
SetPlayerArmour(TargetPlayer, 100);
// Messaggio di avviso
format( szStr, sizeof(szStr), "[ADMIN]: %s ti ha settato l'armatura al massimo", AdminName );
SendClientMessage(TargetPlayer, COLOR_SYSTEM_INFO, szStr );
format( szStr, sizeof(szStr), "[INFO]: Hai settato l'armatura di %s al massimo", TargetPlayerName );
SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, szStr );
return 1;
}
else if (!strcmp(item, "Vita") || !strcmp(item, "vita"))
{
if(sscanf(command, "u", TargetPlayer)) return SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Usa /admin sett armatura [ID/nome giocatore]");
if(!IsPlayerConnected(TargetPlayer)) return SendClientMessage(playerid, COLOR_SYSTEM_ERROR,"[ERRORE]: Il giocatore selezionato non и connesso o id/nome sbagliato");
// Setting dell'armatura al giocatore selezionato
SetPlayerHealth(TargetPlayer, 100);
// Messaggio di avviso
format( szStr, sizeof(szStr), "[ADMIN]: %s ti ha settato la vita al massimo", AdminName );
SendClientMessage(TargetPlayer, COLOR_SYSTEM_INFO, szStr );
format( szStr, sizeof(szStr), "[INFO]: Hai settato la vita di %s al massimo", TargetPlayerName );
SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, szStr );
return 1;
}
else if (!strcmp(item, "money"))
{
// Code for the money...
}
}
else if (!strcmp(option, "SelfSETT") || !strcmp(option, "selfsett"))
{
if (isnull(item))
{
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /admin SelfSETT [Opzione]");
SendClientMessage(playerid, COLOR_WHITE, " OPTIONS: Armatura | Vita");
return 1;
}
if (!strcmp(item, "Armatura") || !strcmp(item, "armatura"))
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, "[INFO]: Ti sei ricaricato l'armatura.");
return 1;
}
else if (!strcmp(item, "Vita") || !strcmp(item, "vita"))
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, "[INFO]: Ti sei ricaricato la vita.");
return 1;
}
else if (!strcmp(item, "money"))
{
// Code for the money...
}
}
}
else if(PlayerInfo[playerid][pAdmin] == 0)
{
SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE]: Non sei autorizzato ad usare questo comando");
return 1;
}
return 1;
}
But didn't work, for example when the admin try the command:
"/admin give soldi [id] [ammount]"
the command didn't work, the console show only this string
"sscanf warning: Strings without a length are deprecated, please add a destination size."
how i can fix it? or if someone can write a similar command? This is for admin, and i need to create for other player that aren't admins, for example in the RP server for putting or takeing something in the hood of the car.


