help command
#1

i want admin cant give weapon minigun +rocket launcher

command:

PHP код:
CMD:giveallweapon(playerid,params[]) {
    if(
PlayerInfo[playerid][Level] >= 5) {
        new 
tmp[128], tmp2[128], IndexammoweapWeapName[32], string[128]; tmp strtok(params,Index), tmp2 strtok(params,Index);
        if(
isnull(tmp) ) return SendClientMessage(playeridred"USAGE: /giveallweapon [weapon id/weapon name] [ammo]");
        if(
isnull(tmp2) || !IsNumeric(tmp2) || strval(tmp2) <= || strval(tmp2) > 99999ammo 500;
        if(!
IsNumeric(tmp)) weap GetWeaponIDFromName(tmp); else weap strval(tmp);
          if(!
IsValidWeapon(weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
          
CMDMessageToAdmins(playerid,"GIVEALLWEAPON");
        for(new 
0MAX_PLAYERSi++) {
            if(
IsPlayerConnected(i)) {
                
PlayerPlaySound(i,1057,0.0,0.0,0.0);
                
GivePlayerWeapon(i,weap,ammo);
            }
        }
        
GetWeaponName(weapWeapNamesizeof(WeapName) );
        
format(string,sizeof(string),"Administrator \"%s\" has given all players a %s (%d) with %d rounds of ammo"pName(playerid), WeapNameweapammo);
        return 
SendClientMessageToAll(bluestring);
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");

Reply
#2

first: check if the weaponid is the minigun or RPG:
https://sampwiki.blast.hk/wiki/Weapons

Then, simply send a message to the player telling him he can't give a minigun/RPG using SendClientMessage

OT: don't use strtok, it's slow and crappy, use sscanf instead!
Reply
#3

pawn Код:
if(weap /* whatever is your variable */ == 38 || weap == 35) return SendClientMessage(playerid, -1, "Illegal weapon.");
Reply
#4

thanks guys this command have a bug !!
how i use sscanf.
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=300397
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)