SA-MP Forums Archive
error 006: must be assigned to an array in my system :( - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error 006: must be assigned to an array in my system :( (/showthread.php?tid=72730)



error 006: must be assigned to an array in my system :( - mirkoiz - 10.04.2009

Hello, i have this Code
pawn Код:
new PlayerName[256];
                GetPlayerName(i, PlayerName, sizeof(PlayerName));
                recordKMH = KMH;
                recordVEHICLE = CarName[GetVehicleModel(GetPlayerVehicleID(i))-400];
                recordNAME = PlayerName;
                format(string, 256, "%s has broken the Speed Record!", PlayerName);
                SendClientMessageToAll(COLOR_WHITE, string);
                format(string, 256, "Record Vehicle: %s",recordVEHICLE);
                SendClientMessageToAll(COLOR_WHITE, string);
                format(string, 256, "KMH: %.0f", KMH);
                SendClientMessageToAll(COLOR_WHITE, string);
and have the Following error:
pawn Код:
C:\Dokumente und Einstellungen\Plato\Desktop\speedo.pwn(154) : error 006: must be assigned to an array
C:\Dokumente und Einstellungen\Plato\Desktop\speedo.pwn(155) : error 006: must be assigned to an array

Error Lines:
pawn Код:
recordVEHICLE = CarName[GetVehicleModel(GetPlayerVehicleID(i))-400];
                recordNAME = PlayerName;
Can any one say me how to fix?


Re: error 006: must be assigned to an array in my system :( - Joe Staff - 10.04.2009

show the line that says "new CarName" and "new recordVEHICLE" and "new recordNAME"


Re: error 006: must be assigned to an array in my system :( - tom_jonez - 10.04.2009


pawn Код:
format(recordVEHICLE,sizeof(recordVEHICLE),"%s",CarName[GetVehicleModel(GetPlayerVehicleID(i))-400]);
                format(recordNAME,sizeof(recordNAME),"%s",PlayerName);
i think thatll do it.


Re: error 006: must be assigned to an array in my system :( - mirkoiz - 10.04.2009

Quote:
Originally Posted by R4nk3d
pawn Код:
format(recordVEHICLE,sizeof(recordVEHICLE),"%s",CarName[GetVehicleModel(GetPlayerVehicleID(i))-400]);
                format(recordNAME,sizeof(recordNAME),"%s",PlayerName);
i think thatll do it.
no it dont do it :P

my New`s:
pawn Код:
new Float:recordKMH;
new recordNAME;
new recordVEHICLE;



Re: error 006: must be assigned to an array in my system :( - tom_jonez - 10.04.2009

change them to:
pawn Код:
new recordNAME[28];
new recordVEHICLE[28];



Re: error 006: must be assigned to an array in my system :( - mirkoiz - 10.04.2009

Quote:
Originally Posted by R4nk3d
change them to:
pawn Код:
new recordNAME[28];
new recordVEHICLE[28];
still the same error


Re: error 006: must be assigned to an array in my system :( - tom_jonez - 10.04.2009

hmm, im not sure. can someone give me a hand?


Re: error 006: must be assigned to an array in my system :( - Joe Staff - 10.04.2009

recordNAME has to be a string equal to PlayerName to do the "recordNAME = PlayerName" line
CarName has a spot for the amount of vehicles and the length of the string "new CarName[MAX_VEHICLE][30]" but when you do that also make sure that recordVEHICLE has the same length for string "new recordVEHIVCLE[30]"


Re: error 006: must be assigned to an array in my system :( - mirkoiz - 10.04.2009

hehe if nobody can help on this way... my whole code:

pawn Код:
#include <a_samp>
#define COLOR_WHITE 0xFFFFFFAA
#define SLOTS 100

forward UpdateSpeed ();

enum SavePlayerPosEnum {
Float:LastX,
Float:LastY,
Float:LastZ
}

forward Recordmessage();

new SavePlayerPos[SLOTS][SavePlayerPosEnum];
new Text:Speedo[SLOTS];
new UpdateSeconds;


new Float:recordKMH;
new recordNAME[28];
new recordVEHICLE[28];
new CarName[][] =
{
  "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
    "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
    "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
    "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
    "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
    "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
    "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
    "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
    "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
    "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
    "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
    "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
    "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
    "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
    "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
    "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
    "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
    "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
    "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
    "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
    "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
    "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
    "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
    "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
    "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
    "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
    "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
    "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
    "Tiller", "Utility Trailer"
};

public OnFilterScriptInit()
{

    SetTimer("UpdateSpeed",1000, 1);
    SetTimer("Recordmessage",300000, 1);
    return 1;
}

public Recordmessage()
{
    new string[256];
    format(string, 256, "Current Speed Record by: %s!", recordNAME);
    SendClientMessageToAll(COLOR_WHITE, string);
    format(string, 256, "Record Vehicle: %s", recordVEHICLE);
    SendClientMessageToAll(COLOR_WHITE, string);
    format(string, 256, "KMH: %.0f", recordKMH);
    SendClientMessageToAll(COLOR_WHITE, string);
    return 1;
}
public OnFilterScriptExit()
{
    for(new i=0; i<SLOTS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            TextDrawDestroy(Speedo[i]);
        }
    }
    return 1;
}

main()
{
}

public OnPlayerConnect(playerid)
{

    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_ONFOOT)
    {
  TextDrawHideForPlayer(playerid, Speedo[playerid]);
    }
    return 1;
}

public UpdateSpeed()
{
    new Float:x,Float:y,Float:z;
    new Float:distance,value,string[256];
    new Float:health;
    for(new i=0; i<SLOTS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            TextDrawDestroy(Speedo[i]);
        }
    }

    for(new i=0; i<SLOTS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            GetPlayerPos(i, x, y, z);
            GetVehicleHealth(GetPlayerVehicleID(i), health);
            distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
            value = floatround(distance * 5000);
            new Float:KMH = floatround(value/1000);
            if(UpdateSeconds > 1)
            {
                value = floatround(value / UpdateSeconds);
            }
            format(string,sizeof(string),"~g~Vehicle : ~w~%s ~n~~b~KM/H : ~w~%.0f~n~~r~Vehicle Health:~w~ %.2f",CarName[GetVehicleModel(GetPlayerVehicleID(i))-400],KMH,health);
            Speedo[i] = TextDrawCreate(320.00, 380.00, string);
            TextDrawSetOutline(Speedo[i], 0);
            TextDrawFont(Speedo[i], 3);
            TextDrawSetProportional(Speedo[i], 2);
            TextDrawAlignment(Speedo[i], 2);
            TextDrawShowForPlayer (i, Speedo[i]);
            if(KMH > recordKMH)
            {
                new PlayerName[256];
                GetPlayerName(i, PlayerName, sizeof(PlayerName));
                recordKMH = KMH;
                recordVEHICLE[28] = CarName[GetVehicleModel(GetPlayerVehicleID(i))-400];
                recordNAME = PlayerName;
                format(string, 256, "%s has broken the Speed Record!", PlayerName);
                SendClientMessageToAll(COLOR_WHITE, string);
                format(string, 256, "Record Vehicle: %s",recordVEHICLE);
                SendClientMessageToAll(COLOR_WHITE, string);
                format(string, 256, "KMH: %.0f", KMH);
                SendClientMessageToAll(COLOR_WHITE, string);
            }
        }
        SavePlayerPos[i][LastX] = x;
        SavePlayerPos[i][LastY] = y;
        SavePlayerPos[i][LastZ] = z;
    }
}