/giveweapon isn't working.
#3

Quote:
Originally Posted by codExpert
View Post
why are you using normal variables and pvars, maybe stick with one solution only
PHP Code:
public OnPlayerCommandPerformed(playeridcmdtext[], success){
    if (
PlayerInfo[playerid][LoggedIn] == false) return SendClientMessage(playeridCOLOR_WHITE"You must be logged in to use this."), 0;
    return 
1;
}
getUserName(pid){
    new 
s[24];
    
GetPlayerName(pid,s,24);
    
GiveNameSpace(s);
    return 
s;
}
getWeaponName(wid){
    new 
s[32];
    
GetWeaponName(wid,s,32);
    return 
s;
}
GivePlayerWeaponEx(playeridweaponidammo)
{
    switch(
weaponid){
        case 
2..15:{
            
SetPVarInt(playerid"MeeleWeapon"weaponid);
            if(
GetPVarInt(playerid"MeeleWeapon") < 0SetPVarInt(playerid"MeeleWeapon"0);
            
GivePlayerWeapon(playeridweaponid1);
        }
        case 
22..24,28..29:{
            
SetPVarInt(playerid"SecondaryWeapon"weaponid);
            
SetPVarInt(playerid"SecondaryWeaponAmmo"ammo);
            if(
GetPVarInt(playerid"SecondaryWeapon") < 0SetPVarInt(playerid"SecondaryWeapon"0);
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
25..27,30..34:{
            
SetPVarInt(playerid"PrimaryWeapon"weaponid);
            
SetPVarInt(playerid"PrimaryAmmo"ammo);
            if(
GetPVarInt(playerid"PrimaryWeapon") < 0SetPVarInt(playerid"PrimaryWeapon"0);
            
GivePlayerWeapon(playeridweaponidammo);
        }
        default:{
            
SendClientMessage(playeridCOLOR_ORANGE"Error: That weapon isn't part of the script or can be bought at a 24/7");
        }
    }
    return 
1;
}
COMMAND:giveweapon(playeridparams[])
{
    if(
GetPVarInt(playerid"Admin") < 3)return SendClientMessage(playeridCOLOR_GREY"You are not admin!");
    new 
targetid,weaponid,ammo;
    if(
sscanf(params"uii"targetidweaponidammo)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /giveweapon [player] [weapon] [ammo]");
    if (!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_WHITE"This player is not connected !");
    
//giving weapon : changed playerid to targetid
    
GivePlayerWeaponEx(targetid,weaponid,ammo);
    
//message for players
    
format(s,90,"Server: %s has given %s to %s.",getUserName(playerid),getWeaponName(weaponid),getUserName(targetid));
    
SendAdminMessage(COLOR_ORANGEs);
    
AdminLog(playerid,"giveweapon",s);
    return 
1;

u need to add to onplayercommandperformed that u also cant use any cmd if ur not spawned
Reply


Messages In This Thread
/giveweapon isn't working. - by TheLeech - 20.01.2019, 18:51
Re: /giveweapon isn't working. - by codExpert - 20.01.2019, 20:50
Re: /giveweapon isn't working. - by Stefhan - 20.01.2019, 21:53
Re: /giveweapon isn't working. - by codExpert - 20.01.2019, 22:15
Re: /giveweapon isn't working. - by SeeNN - 20.01.2019, 22:25
Re: /giveweapon isn't working. - by codExpert - 20.01.2019, 22:33
Re: /giveweapon isn't working. - by SeeNN - 21.01.2019, 00:50

Forum Jump:


Users browsing this thread: 1 Guest(s)