03.05.2011, 16:23
Hi guys! I've made a /giveweapon command, where you specify the weapon ID and the amount of ammo. However, whatever i type in as ammo it will come out as 0. This is the code:
Thanks in advance!
Donut Seller
pawn Код:
command(agiveweapon, playerid, params[])
{
new WeaponN[ 60 ], Names[ 2 ][ MAX_PLAYER_NAME ], string[ 128 ], id, weaponid, ammo;
if( sscanf( params, "ud", id, weaponid, ammo ) )
{
if( Player[playerid][AdminLevel] >= 3 )
{
SendClientMessage( playerid, COLOR_GREY, "SYNTAX: /agiveweapon [playerid/name] [weaponid] [ammo] " );
}
else
{
SendClientMessage( playerid, COLOR_GREY, "You are not authorized to use that command.");
}
}
else
{
if( Player[playerid][AdminLevel] >= 3 )
{
if(IsPlayerConnectedEx(id) )
{
if(weaponid >= 1 && weaponid < 47)
{
GetPlayerName( id, Names[ 0 ], MAX_PLAYER_NAME );
GetPlayerName( playerid, Names[ 1 ], MAX_PLAYER_NAME );
if(weaponid == 19)
{
SendClientMessage(playerid, COLOR_GREY, "Please use /jetpack instead.");
}
else if(weaponid == 38)
{
if(IsPlayerAdmin(playerid))
{
GetWeaponName(weaponid, WeaponN, sizeof(WeaponN) );
GivePlayerWeapon(id, weaponid, ammo);
format( string, sizeof( string ), "You have given %s a %s (Weapon ID: %d. Ammo: %d).", UnderscoreToSpaceName(id), WeaponN, weaponid, ammo);
SendClientMessage( playerid, COLOR_LIGHTBLUE, string);
format( string, sizeof( string ), "Admin %s has given you a %s. Ammo: %d", UnderscoreToSpaceName(playerid), WeaponN, ammo );
SendClientMessage(id, COLOR_LIGHTBLUE, string);
format( string, sizeof( string ), "[ADMMSG:] Admin %s has given %s a %s. (Ammo: %d)", Names[ 1 ], Names[ 0 ], WeaponN, ammo);
SendToAdmins(ADMINACTION, string, 1);
AdminActionsLog( string );
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to spawn that weapon.");
}
}
else
{
GetWeaponName(weaponid, WeaponN, sizeof(WeaponN) );
GivePlayerWeapon(id, weaponid, ammo);
format( string, sizeof( string ), "You have given %s a %s (Weapon ID: %d. Ammo: %d).", UnderscoreToSpaceName(id), WeaponN, weaponid, ammo);
SendClientMessage( playerid, COLOR_LIGHTBLUE, string);
format( string, sizeof( string ), "Admin %s has given you a %s. Ammo: %d", UnderscoreToSpaceName(playerid), WeaponN, ammo );
SendClientMessage(id, COLOR_LIGHTBLUE, string);
format( string, sizeof( string ), "[ADMMSG:] Admin %s has given %s a %s. (Ammo: %d)", Names[ 1 ], Names[ 0 ], WeaponN, ammo);
SendToAdmins(ADMINACTION, string, 1);
AdminActionsLog( string );
}
}
else
{
SendClientMessage( playerid, COLOR_GREY, "Invalid weapon ID." );
}
}
else
{
SendClientMessage( playerid, COLOR_GREY, "Invalid ID." );
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command.");
}
}
return 1;
}
Donut Seller