/giveallweapon doesnt work
#1

command /giveallweapon from LuxAdmin doesnt work.. how to fix?

Код:
dcmd_giveallweapon(playerid,params[])
{
	if(AccInfo[playerid][Level] >= 3)
	{
	    new tmp[256], tmp2[256], Index;
		new ammo, weap, WeapName[32];
		new string[128];
		tmp = strtok(params,Index); tmp2 = strtok(params,Index);
	    if(!strlen(tmp)) return
	    SendClientMessage(playerid, LIGHTBLUE2, "Usage: /giveallweapon [WeaponID or WeaponName] [Ammo]") &&
		SendClientMessage(playerid, orange, "Function: Will give a specified weapon and ammo for all players");
		
		if(!strlen(tmp2) || !IsNumeric(tmp2) || strval(tmp2) <= 0 || strval(tmp2) > 99999) ammo = 500;
		if(!IsNumeric(tmp))
		weap = GetWeaponIDFromName(tmp);
		else weap = strval(tmp);
	  	if(!IsValidWeapon(weap))
  		return SendClientMessage(playerid,red,"ERROR: Invalid Weapon ID");
      	SendCommandToAdmins(playerid,"GiveAllWeapon");
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
			PlayerPlaySound(i,1057,0.0,0.0,0.0);
			GivePlayerWeapon(i,weap,ammo);
			}
		}
		GetWeaponName(weap, WeapName, sizeof(WeapName));
		format(string,sizeof(string),"All Players received a %s (%d) with %d rounds of Ammo", WeapName, weap, ammo);
		return SendClientMessageToAll(pmsg, string);
	}
	else return ErrorMessages(playerid, 1);
it gives correctly the weapon but with 0 ammo's, even if you specify 999 ammo's.

whats the problem?
Reply
#2

I don't know if you wrongfully pasted the command but you forgot a } at the end.Also,what function is "SendCommandToAdmins(playerid,"GiveAllWeapon") ;" ...? Is to send an admin message about the command execution?

Try:

pawn Код:
dcmd_giveallweapon(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 3)
    {
        new tmp[128], tmp2[128], Index;
        new ammo, weap, WeapName[32];
        new string[128];
        tmp = strtok(params,Index); tmp2 = strtok(params,Index);
        if(!strlen(tmp)) return
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /giveallweapon [WeaponID or WeaponName] [Ammo]") &&
        SendClientMessage(playerid, orange, "Function: Will give a specified weapon and ammo for all players");

        if(!strlen(tmp2) || !IsNumeric(tmp2) || strval(tmp2) <= 0 || strval(tmp2) > 99999) ammo = 500;
        if(!IsNumeric(tmp))
        weap = GetWeaponIDFromName(tmp);
        else weap = strval(tmp);
        if(!IsValidWeapon(weap))
        return SendClientMessage(playerid,red,"ERROR: Invalid Weapon ID");
        SendCommandToAdmins(playerid,"GiveAllWeapon");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
            PlayerPlaySound(i,1057,0.0,0.0,0.0);
            GivePlayerWeapon(i,weap,ammo);
            }
        }
        GetWeaponName(weap, WeapName, sizeof(WeapName));
        format(string,sizeof(string),"All Players received a %s (%d) with %d rounds of Ammo", WeapName, weap, ammo);
        return SendClientMessageToAll(pmsg, string);
    }
    else return ErrorMessages(playerid, 1);
}
You don't need a tmp of 256 cells.
Reply
#3

pawn Код:
dcmd_giveallweapon(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 3)
    {
        new tmp[256], tmp2[256], Index;
        new ammo, weap, WeapName[32];
        new string[128];
        tmp = strtok(params,Index); tmp2 = strtok(params,Index);
        if(!strlen(tmp)) return
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /giveallweapon [WeaponID or WeaponName] [Ammo]") &&
        SendClientMessage(playerid, orange, "Function: Will give a specified weapon and ammo for all players");
       
        if(!strlen(tmp2) || !IsNumeric(tmp2) || strval(tmp2) <= 0 || strval(tmp2) > 99999) ammo = 500;
        if(!IsNumeric(tmp))
        weap = GetWeaponIDFromName(tmp);
        else weap = strval(tmp);
                      ammo = strval(tmp2)
        if(!IsValidWeapon(weap))
        return SendClientMessage(playerid,red,"ERROR: Invalid Weapon ID");
        SendCommandToAdmins(playerid,"GiveAllWeapon");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
            PlayerPlaySound(i,1057,0.0,0.0,0.0);
            GivePlayerWeapon(i,weap,ammo);
            }
        }
        GetWeaponName(weap, WeapName, sizeof(WeapName));
        format(string,sizeof(string),"All Players received a %s (%d) with %d rounds of Ammo", WeapName, weap, ammo);
        return SendClientMessageToAll(pmsg, string);
    }
    else return ErrorMessages(playerid, 1);
Maybe because you didn't set 'ammo' variable value?
Reply
#4

thanks man, +1 rep for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)