String combination in code
#5

My code is now this:

Код:
    if (strcmp(cmd, "/weapon", true) == 0) {
      if (cmdtext[7] == 0) {
        SendClientMessage(playerid, COLOR_RED, "Usage: /weapon [weapon number], '/weapon help[0-11]' for weapon numbers.");
				return 1;
      }
      
      if (cmdtext[8] == 0) {
        SendClientMessage(playerid, COLOR_RED, "Usage: /weapon [weapon number], '/weapon help[0-11]' for weapon numbers.");
        return 1;
      }
      
      new packnumber[7];
      format(packnumber, sizeof(packnumber), cmdtext[8]);
      
      if (strcmp(packnumber, "help") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 0: Vist, Slot 1: Melee, Slot 2: Pistols, Slot 3: Shotguns");
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 4: SMG's, Slot 5: Assault, Slot 6: Rifles, Slot 7: Launcher & Minigun");
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 8: Bombs, Slot 9: Specials, Slot 10: Special melee, Slot 11: Visions & Parachute");
        return 1;
      }
      
      if (strcmp(packnumber, "help0") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 0: Reset all weapons - 0, Unarmed - 1, Brass knuckles - 2");
        return 1;
      }
      
      if (strcmp(packnumber, "help1") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 1: Golf club - 3, Nite stick - 4, Knife - 5, Baseball bat - 6");
      	SendClientMessage(playerid, COLOR_YELLOW, "Shovel - 7, Pool cue - 8, Katana - 9, Chainsaw - 10");
        return 1;
      }
      
      if (strcmp(packnumber, "help2") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 2: 9mm - 11, Silenced 9mm - 12, Desert Eagle - 13");
        return 1;
      }
      
      if (strcmp(packnumber, "help3") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 3: Shotgun - 14, Sawnoff shotgun - 15, Combat Shotgun - 16");
        return 1;
      }
      
      if (strcmp(packnumber, "help4") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 4: Micro SMG - 17, SMG - 18, Tec 9 - 19");
        return 1;
      }
      
      if (strcmp(packnumber, "help5") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 5: AK47 - 20, M4 - 21");
        return 1;
      }
      
      if (strcmp(packnumber, "help6") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 6: Country rifle - 22, Sniper rifle - 23");
        return 1;
      }
      
      if (strcmp(packnumber, "help7") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 7: Rocket Launcher - 24, HS Rocket Launcher - 25, Flamethrower - 26");
      	SendClientMessage(playerid, COLOR_YELLOW, "Minigun - 27");
        return 1;
      }
      
      if (strcmp(packnumber, "help8") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 8: Satchel Charge - 28, Grenade - 29, Tear Gas - 30, Molotov Cocktail - 31");
        return 1;
      }
      
      if (strcmp(packnumber, "help9") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 9: Spraycan - 32, Fire Extinguisher - 33, Camera - 34");
        return 1;
      }
      
      if (strcmp(packnumber, "help10") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 10: Purple Dildo - 35, Small White Vibrator - 36, Large White Vibrator - 37");
      	SendClientMessage(playerid, COLOR_YELLOW, "Silver Vibrator - 38, Flowers - 39, Cane - 40");
        return 1;
      }
      
      if (strcmp(packnumber, "help11") == 0) {
      	SendClientMessage(playerid, COLOR_YELLOW, "Slot 11: Nightvision Goggles - 41, Infrared Vision - 42, Parachute - 43");
        return 1;
      }
      
      new weap[43] = {
			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 22, 23, 24, 25, 26, 27, 28, 29, 32, 30, 31, 33, 34, 35,
			36, 37, 38, 39, 16, 17, 18, 41, 42, 43, 10, 11, 12, 13, 14, 15, 44, 45, 46 //weapon id's
			};
			
 			new ID = strval(cmdtext[8]);
			GivePlayerWeapon(playerid, weap[ID], 500);
			return 1;
    }
And it works, except that all numbers are one too far, because I want reset all weapons on 0. But i'll fix that later.

But i really don't understand what it does, That "weap[43]..." and "weap[ID]".
Reply


Messages In This Thread
String combination in code - by pascallj - 27.06.2009, 20:49
Re: String combination in code - by dice7 - 27.06.2009, 20:54
Re: String combination in code - by pascallj - 27.06.2009, 20:57
Re: String combination in code - by dice7 - 27.06.2009, 21:24
Re: String combination in code - by pascallj - 28.06.2009, 13:31
Re: String combination in code - by pascallj - 28.06.2009, 18:02

Forum Jump:


Users browsing this thread: 3 Guest(s)