SA-MP Forums Archive
Help with Command Hunted ! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with Command Hunted ! (/showthread.php?tid=633316)



Help with Command Hunted ! - FizzyWalshy - 29.04.2017

Remove -Fixed.


Re: Help with Command Hunted ! - NealPeteros - 29.04.2017

Which is line 16946?


Re: Help with Command Hunted ! - Sew_Sumi - 29.04.2017

Код:
new giveplayerid;
		new weapon[128];
		new price;
		new gun1,
		gun2,
		gun3,
		prizetype,
	    if(PlayerInfo[giveplayerid][pWantedLevel] >= 1 && PlayerInfo[giveplayerid][pWantedLevel] <= 6))
	    {
	        return SendClientMessage(playerid, COLOR_GRAD3, "That player has a wanted level.");
		}

		if(sscanf(params, "uiiii", giveplayerid, gun1, gun2, gun3, prizetype, price))
		{
			SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /hunted [playerid/partofname] [gun] [gun2] [gun3] [prize]");
			SendClientMessage(playerid, COLOR_GREY, "Available weapons: Chainsaw, Flamethrower, Rocketlauncher, Fire Extinguisher, Spas, Deagle");
			SendClientMessage(playerid, COLOR_GREY, "Available prizes: Mats and Crack (400 materials, 20 crack), Jetpack, Full weaponset");
			return 1;

			else if(gun1 > 39 || gun1 < 0) return SendClientMessage(playerid,COLOR_GRAD2,"	Invalid weapon id? Use weapon IDs within 0-39!");
			else if(gun2 > 39 || gun2 < 0) return SendClientMessage(playerid,COLOR_GRAD2,"	Invalid weapon id? Use weapon IDs within 0-39!");
			else if(gun1 > 39 || gun3 < 0) return SendClientMessage(playerid,COLOR_GRAD2,"	Invalid weapon id? Use weapon IDs within 0-39!");
		}
		else
		{
			if(giveplayerid != playerid))
			{
  				GivePlayerValidWeapon(giveplayerid, gun, 60000);
	    		GivePlayerValidWeapon(giveplayerid, gun2, 60000);
		    	GivePlayerValidWeapon(giveplayerid, gun3, 60000);
		    	SetPlayerColor(playerid, 0xFF80FFFF);
		    	hunted = giveplayerid;
		    	Phunted[giveplayerid] = 1;
			}
		}
You create a variable giveplayerid, and don't assign a value to it... Because of that the code is screwed from the start.

You then check giveplayerids wanted level, THEN check if the params for sscanf have anything to assign giveplayerid.

Then your else statement, checks if the playerid != giveplayerid.


This is just bad coding...


Re: Help with Command Hunted ! - FizzyWalshy - 29.04.2017

Ok i will change playerid to giveplayerid


Re: Help with Command Hunted ! - Sew_Sumi - 29.04.2017

Quote:
Originally Posted by FizzyWalshy
Посмотреть сообщение
Ok i will change playerid to giveplayerid
That's not going to fix this at all...


Not in the slightest.

You're trying to make a command that makes the playerid you input in the command (giveplayerid) to be 'hunted', which, in the command you are creating giveplayerid, yet not setting it.

You then check giveplayerid, when it's not set.

You then use sscanf to check the parameters, for giveplayerid.


This is where copy-pasting gets you... You don't understand the flow of the command, nor how to actually do what you want to do, due to simply modifying commands thinking that it'll work, when it doesn't.

Another problem is this...

Код:
new gun1,
		gun2,
		gun3,
		prizetype,
It should be

Код:
new gun1,
		gun2,
		gun3,
		prizetype;
This is another issue...

Код:
if(sscanf(params, "uiiii", giveplayerid, gun1, gun2, gun3, prizetype, price))
You have user, int, int, int, int... Matching out to giveplayerid, gun1, gun2, gun3, prizetype...

Price is simply you taking /sellgun from a random script and mistakenly leaving that in there, as it should throw an error saying there's too many arguments on that function.

With what you've put in the command help, you can't simply make an assumption that you can put in words into the command and have it output correctly... It's not going to pick up that you want to give 'mats' 'crack' weaponset' magically.

Not to mention, you have this prizetype variable created, yet you also don't even use it at all in the command.