05.02.2012, 06:01
(
Последний раз редактировалось jamesbond007; 05.02.2012 в 06:37.
)
Ok, i'm trying to make a giveweapon command, It works like this:
the weapon can be written as an id or a weapon name, but i want to make like this: if you don't specify the ammo field, it will be 400 by default.
the weapon name works, but weapon id's dont work, it just says invalid weapon id.. i need to know why. rep will be given =]
the weapon can be written as an id or a weapon name, but i want to make like this: if you don't specify the ammo field, it will be 400 by default.
the weapon name works, but weapon id's dont work, it just says invalid weapon id.. i need to know why. rep will be given =]
pawn Код:
CMD:giveweapon(playerid, params[])
{
if(PlayerInfo[playerid][Level]>0)
{
new id,wepname[24],wepid,ammo;
if(!sscanf(params,"us[24]D(400)",id,wepname,ammo))
{
if(IsPlayerConnected(id)&&id!=INVALID_PLAYER_ID)
{
wepid = GetWeaponIDFromName(wepname);
if(IsValidWeapon(wepid))
{
CMDMessageToAdmins(playerid,"GIVEWEAPON");
new str[128];
format(str,sizeof(str),"You have given %s (%d) a weapon %s with %d ammo.",PlayerName(id),id,wepname,ammo);
SendClientMessage(playerid, LIGHTBLUE, str);
format(str,sizeof(str),"Administrator %s has gave you a gun %s with %d ammo.",PlayerName(playerid),wepname,ammo);
SendClientMessage(id, LIGHTBLUE, str);
GivePlayerWeapon(id, wepid, ammo);PlayerPlaySound(id,1057,0.0,0.0,0.0);PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}
else return SendClientMessage(playerid, RED, "Invalid Weapon ID.");
}
else return SendClientMessage(playerid, RED, "Invalid Player ID.");
}
else if(!sscanf(params,"udD(400)",id,wepid,ammo))
{
if(IsValidWeapon(wepid))
{
CMDMessageToAdmins(playerid,"GIVEWEAPON");
new str[128];
GetWeaponName(wepid,wepname,sizeof(wepname));
format(str,sizeof(str),"You have given %s (%d) a weapon %s with %d ammo.",PlayerName(id),id,wepname,ammo);
SendClientMessage(playerid, LIGHTBLUE, str);
format(str,sizeof(str),"Administrator %s has gave you a gun %s with %d ammo.",PlayerName(playerid),wepname,ammo);
SendClientMessage(id, LIGHTBLUE, str);
GivePlayerWeapon(id, wepid, ammo);PlayerPlaySound(id,1057,0.0,0.0,0.0);PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}
else return SendClientMessage(playerid, RED, "Invalid Weapon ID.");
}
else return SendClientMessage(playerid, RED, "Usage: /giveweapon [id] [wepid] [ammo]");
}
else return SendClientMessage(playerid, RED, "Invalid Command - Type /cmds for commands list.");
return 1;
}