Give weapon command not works
#1

Hello,my give weapon admin command not works.It not gives weapon to player.
Код:
dcmd_giveweapon(playerid, params[])
{
    new pID, weap, ammo;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "ud", pID, weap,ammo)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveweapon [playerid] [weaponid] [amount of ammo]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        if(weap == 35 && 36 && 38)
        {
        SendClientMessage(playerid, COLOR_RED, "This weapon is disabled in our server");
        }
        else if(!IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        else{
        GivePlayerWeapon(pID,weap,ammo);
        }
    }
    else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
Any help ?
Reply
#2

You are missing a d in "ud"

pawn Код:
dcmd_giveweapon(playerid, params[])
{
    new pID, weap, ammo;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "udd", pID, weap,ammo)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveweapon [playerid] [weaponid] [amount of ammo]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        if(weap == 35 && 36 && 38)
        {
        SendClientMessage(playerid, COLOR_RED, "This weapon is disabled in our server");
        }
        else if(!IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        else{
        GivePlayerWeapon(pID,weap,ammo);
        }
    }
    else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
Reply
#3

pawn Код:
dcmd_giveweapon(playerid, params[])
{
    new pID, weap, ammo;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "udd", pID, weap,ammo)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveweapon [playerid] [weaponid] [amount of ammo]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        if(weap == 35 && 36 && 38)
        {
        SendClientMessage(playerid, COLOR_RED, "This weapon is disabled in our server");
        }
        else if(!IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        else{
        GivePlayerWeapon(pID,weap,ammo);
        }
    }
    else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
Should work now, tested it for you.
Reply
#4

Quote:
Originally Posted by Pz
Посмотреть сообщение
pawn Код:
dcmd_giveweapon(playerid, params[])
{
    new pID, weap, ammo;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "udd", pID, weap,ammo)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveweapon [playerid] [weaponid] [amount of ammo]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        if(weap == 35 && 36 && 38)
        {
        SendClientMessage(playerid, COLOR_RED, "This weapon is disabled in our server");
        }
        else if(!IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        else{
        GivePlayerWeapon(pID,weap,ammo);
        }
    }
    else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
Should work now, tested it for you.
But Meyer posted already? i guess.
Reply
#5

....
Reply
#6

try:
pawn Код:
dcmd_giveweapon(playerid, params[])
{
    new pID, weap, ammo;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "udd", pID, weap,ammo)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveweapon [playerid] [weaponid] [amount of ammo]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        if(weap == 35 && 36 && 38) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        {
        SendClientMessage(playerid, COLOR_RED, "This weapon is disabled in our server");
        }
        else{
        GivePlayerWeapon(pID,weap,ammo);
        }
    }
    else if(PlayerInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
NOT TESTED AT ALL!
Reply
#7

Quote:
Originally Posted by Clive
Посмотреть сообщение
But Meyer posted already? i guess.
Copy pasting will fail soon.
Reply
#8

First why do you want if(wep == 35 && 36 && 38 ) you need if(wep == 35 || 36 || 38 ).

&& - Means "and" so if(wep == 35 and 36 and 38 ) <-- This will not work because you can only input 1 integer for wep.

|| - Means "or" so if(wep == 35 or 36 or 38 ) <-- This should work because it is asking if 35 or 36 or 38 is inputed then return.


pawn Код:
dcmd_giveweapon(playerid, params[])
{
    new pID, weap, ammo;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "ud", pID, weap,ammo)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveweapon [playerid] [weaponid] [amount of ammo]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        if(weap == 35 || 36 || 38)return SendClientMessage(playerid, COLOR_RED, "This weapon is disabled in our server");
        if(IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        GivePlayerWeapon(pID,weap,ammo);
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
Reply
#9

Tee you did not use the or statement right.

pawn Код:
dcmd_giveweapon(playerid, params[])
{
    new pID, weap, ammo;
    if(PlayerInfo[playerid][pAdminLevel] >= 1)
    {
        if(sscanf(params, "ud", pID, weap,ammo)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /giveweapon [playerid] [weaponid] [amount of ammo]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
        if(weap == 35 || weap == 36 || weap == 38)return SendClientMessage(playerid, COLOR_RED, "This weapon is disabled in our server");
        if(!IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
        GivePlayerWeapon(pID,weap,ammo);
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not admin.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)