Help New Fraction Cars
#1

hi guys i need help there
(53517) : error 032: array index out of bounds (variable "hamccar")
(26453) : error 032: array index out of bounds (variable "hamccar")




line(53517)
Код:
hamccar[22] = AddStaticVehicle(443,-2794.4749,-351.7719,7.7295,0.7121,0,0);





line(26453)
Код:
if(newcar >= hamccar[0] && newcar <= hamccar[22])
		{
			if(PlayerInfo[playerid][pLeader] == 24 || PlayerInfo[playerid][pMember] == 24) { }
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "Ar Xar Forsage-is Wevri!");
				RemovePlayerFromVehicleAC(playerid);
			}
		}
help me please.
Reply
#2

up,help guys.
Reply
#3

You defined "hamccar" under a callback, right? Well that restricts its usage to that callback only, try defining it at the beginning of your gamemode.
Reply
#4

new hamccar[22];

hamccar[0] = Add....
hamccar[1] = AddAnother...
....
Do not add other vehicles in-between this list
hamccar[21] = ... must be made

if (newcar >= hamccar[0] && newcar <= hamccar[sizeof(hamccar)] && (hamccar != 0 || hamccar != -1))
Reply
#5

thanks it works now,thanks
Reply
#6

okay pawno is working but now i have one problem,if player is not a member of this fraction he can`t sit in the car right ? in this situation everyone can sit in cars why idk there is this

Код:
		if(newcar >= hamccar[0] && newcar <= hamccar[22])
		{
			if(PlayerInfo[playerid][pLeader] == 24 || PlayerInfo[playerid][pMember] == 24) { }
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "Ar Xar Forsage-is Wevri!");
				RemovePlayerFromVehicleAC(playerid);
			}
		}
what i did wrong ?
Reply
#7

Make a function at the bottom of your script like this:
Код:
IsHamcCar(vehicleid)
{
    for(new i, n = sizeof(hamccar); i < n; i++)
    {
         if(vehicleid == hamccar[i]) return true;
    }
    return false;
}
And replace
Код:
if(newcar >= hamccar[0] && newcar <= hamccar[22])
		{
			if(PlayerInfo[playerid][pLeader] == 24 || PlayerInfo[playerid][pMember] == 24) { }
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "Ar Xar Forsage-is Wevri!");
				RemovePlayerFromVehicleAC(playerid);
			}
		}
With
Код:
if(IsHamcCar(newcar))
{
    if(PlayerInfo[playerid][pLeader] != 24 && PlayerInfo[playerid][pMember] != 24)
    {
        SendClientMessage(playerid, COLOR_GREY, "Ar Xar Forsage-is Wevri!");
        RemovePlayerFromVehicleAC(playerid);
    }
}
Reply
#8

ok now

(26436) : error 017: undefined symbol "IsHamccar"

Код:
	if(IsHamcCar(newcar))
        {
           if(PlayerInfo[playerid][pLeader] != 24 && PlayerInfo[playerid][pMember] != 24)
          {
             SendClientMessage(playerid, COLOR_GREY, "Ar Xar Forsage-is Wevri!");
             RemovePlayerFromVehicleAC(playerid);
          }
        }
(26380) : error 017: undefined symbol "IsHamccar"

Код:
		IsHamcCar(vehicleid)
        {
           for(new i, n = sizeof(hamccar); i < n; i++)
           {
           if(vehicleid == hamccar[i]) return true;
          }
          return false;
        }
(2638 : warning 225: unreachable code
Код:
		if(IsAPlane(newcar))
		{
(26384) : error 017: undefined symbol "vehicleid"

Код:
        if(vehicleid == hamccar[i]) return true;
i must define vehicleid and IshamcCar?
Reply
#9

Bump
Reply
#10

It's IsHamcCar not IsHamccar
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)