Argument mismatch
#1

At the top of the script:
Код:
new siren1[MAX_VEHICLES];
new siren2[MAX_VEHICLES];
Код:
CMD:siren(playerid, params[])
{
	new option[5], string[128];
	new vid = GetPlayerVehicleID(playerid);
	if(PlayerInfo[playerid][pAdmin] < 4) return SCM(playerid, COLOR_GREY, "unauthorized");
	if(sscanf(params,"s", option)) return SCM(playerid, COLOR_GREY,"Usage: /siren [dash | roof | off]");
	if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_GREY,"You need to be in a vehicle");
	{
	    if(!strcmp(option, "dash", true))
	    {
		    switch (GetVehicleModel(vid))
			{
				case 541://bullet
				{
	
					AttachObjectToVehicle(siren1, vid, 0.000500,0.123000,0.299999,0.000000,0.000000,0.000000);
				}
				case 426://premier
				{
					AttachObjectToVehicle(siren1, vid, 0.524999,0.749999,0.40000,0.000000,0.000000,0.000000);
					AttachObjectToVehicle(siren2, vid, 0.000000,-1.50000,0.299999,0.000000,0.000000,0.000000);
				}
				case 560://sultan
				{
					AttachObjectToVehicle(siren1, vid, 0.524999,0.749999,0.40000,0.000000,0.000000,0.000000);
					AttachObjectToVehicle(siren2, vid, 0.000000,-1.2500000,0.299999,0.000000,0.000000,0.000000);
				}
				case 490://FBI
				{
					AttachObjectToVehicle(siren1, vid, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
				}
				case 429://banshee
				{
					AttachObjectToVehicle(siren1, vid, 0.000500,0.123000,0.299999,0.000000,0.000000,0.000000);
					
				}
				case 489://rancher
				{
     				AttachObjectToVehicle(siren1, vid, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
				}
  				case 495://sand dune
				{
					AttachObjectToVehicle(siren1, vid, 0.005000,0.125000,1.000500,0.000000,0.000000,0.000000);
				}
				case 579://huntlye
				{
			 		AttachObjectToVehicle(siren1, vid, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
				}
				case 415://cheetah
				{
					AttachObjectToVehicle(siren1, vid, 0.120500,0.000000,0.605000,0.000000,0.000000,0.000000);
				}
				case 420://taxi
				{
					AttachObjectToVehicle(siren1, vid, 0.524999,0.749999,0.40000,0.000000,0.000000,0.000000);
					AttachObjectToVehicle(siren2, vid, 0.000000,-1.00000,0.299999,0.000000,0.000000,0.000000);
				}
				case 554://yosemite
				{
			 		AttachObjectToVehicle(siren1, vid, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
				}
				case 576://tornado
				{
		  			AttachObjectToVehicle(siren1, vid, 0.524999,0.749999,0.40000,0.000000,0.000000,0.000000);
				}
				case 533://premier
				{
					AttachObjectToVehicle(siren1, vid, 0.524999,0.749999,0.40000,0.000000,0.000000,0.000000);
					AttachObjectToVehicle(siren2, vid, 0.000000,-1.50000,0.299999,0.000000,0.000000,0.000000);
				}
				case 402://buffalo
				{
					AttachObjectToVehicle(siren1, vid, 0.000500,0.123000,0.299999,0.000000,0.000000,0.000000);
				}
	            default:
				{
					return SendClientMessage(playerid, 0xAFAFAFFF, "Vehicle doesn't support that slot!");
				}
	  		}
		}
		if(!strcmp(option, "roof", true))
		{
            switch (GetVehicleModel(vid))
			{
				case 541://bullet
				{
					AttachObjectToVehicle(siren2, vid, -0.010000,0.125000,0.500000,0.000000,0.000000,0.000000);
				}
				case 426://premier
				{
                    AttachObjectToVehicle(siren2, vid, -0.010000,0.125000,0.500000,0.000000,0.000000,0.000000);
				}
				case 560://sultan
				{
					AttachObjectToVehicle(siren2, vid, -0.010000,0.125000,0.500000,0.000000,0.000000,0.000000);
				}
				case 490://FBI
				{
					AttachObjectToVehicle(siren2, vid, 0.005000,0.125000,1.000500,0.000000,0.000000,0.000000);
				}
				case 482://burrito
				{
					AttachObjectToVehicle(siren1, vid, 0.175000,0.500000,1.000000,0.000000,0.000000,0.000000);
				}
				case 489://rancher
				{
					AttachObjectToVehicle(siren2, vid, 0.005000,0.125000,1.000500,0.000000,0.000000,0.000000);
				}
	            case 495://sand dune
				{
					AttachObjectToVehicle(siren2, vid, 0.005000,0.125000,1.000500,0.000000,0.000000,0.000000);
				}
				case 579://huntlye
				{
					AttachObjectToVehicle(siren2, vid, 0.005000,0.125000,1.250000,0.000000,0.000000,0.000000);
				}
				case 415://cheetah
				{
					AttachObjectToVehicle(siren1, vid, 0.120500,0.000000,0.200000,0.000000,0.000000,0.000000);
				}
				case 554://yosemite
				{
					AttachObjectToVehicle(siren2, vid, 0.0000,0.100000,1.000000,0.000000,0.000000,0.000000);
					
				}
				case 576://tornado
				{
					AttachObjectToVehicle(siren1, vid, 0.005000,0.125000,1.000000,0.000000,0.000000,0.000000);
				}
				case 470://patir
				{
					AttachObjectToVehicle(siren2, vid, 0.005000,0.125000,1.000500,0.000000,0.000000,0.000000);
				}
				case 402://buffalo
				{
					AttachObjectToVehicle(siren2, vid, 0.00000,-0.5000,0.700000,0.000000,0.000000,0.000000);
				}
	            default:
				{
					return SendClientMessage(playerid, 0xAFAFAFFF, "Vehicle doesn't support that slot!");
				}
	  		}
		}
		if(!strcmp(option, "off", true))
		{
		    DestroyObject(siren1)
		    DestroyObject(siren2)
		}
	}
	return 1;
}
Made this command, keeps giving me errors.

Код:
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3732) : error 033: array must be indexed (variable "siren1")
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3733) : error 033: array must be indexed (variable "siren2")
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3734) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3738) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3739) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3743) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3744) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3748) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3752) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3757) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3761) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3765) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3769) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3773) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3774) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3778) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3782) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3786) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3787) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3791) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3805) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3809) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3813) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3817) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3821) : error 035: argument type mismatch (argument 1)
C:\Users\Scoot\Desktop\Roleplay\gamemodes\rp.pwn(3825) : error 035: argument type mismatch (argument 1)

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
Reply
#2

Hello.

In your section of code, you just need to replace all copies of siren1 with siren1[vid] and siren2 with siren2[vid].
I'm assuming the cell in each array you want to reference is the vehicle ID of the vehicle you are attaching the siren to.

Explanation:
Your variables siren1 and siren2 are arrays. They can store multiple values.
Here you have said that they can store 1 value for every vehicle you can create by stating their size between the [ and ] to MAX_VEHICLES.

In your section of code, you have used these two variables without specifying what cell you are referencing.
So instead of doing:
pawn Код:
siren1[Put the cell ID here]
//e.g.
siren1[0]
siren1[102]
siren2[340]
You have done:
pawn Код:
siren1
siren2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)