Debug, OnPlayerConnect.
#1

So onplayerconnect..

pawn Код:
public OnPlayerConnect(playerid)
{
    new file[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file),"Cars/%s.ini",name);
    if(dini_Exists(file))
    {
        VehicleInfo[playerid][Model] = dini_Int(file, "Model");
        VehicleInfo[playerid][Price] = dini_Int(file, "Price");
        VehicleInfo[playerid][CarX] = dini_Float(file, "X");
        VehicleInfo[playerid][CarY] = dini_Float(file, "Y");
        VehicleInfo[playerid][CarZ] = dini_Float(file, "Z");
        VehicleInfo[playerid][CarRot] = dini_Float(file, "Rot");
        VehicleInfo[playerid][Locked] = dini_Int(file, "Locked");
        VehicleInfo[playerid][mod1] = dini_Int(file, "mod1");
        VehicleInfo[playerid][mod2] = dini_Int(file, "mod2");
        VehicleInfo[playerid][mod3] = dini_Int(file, "mod3");
        VehicleInfo[playerid][mod4] = dini_Int(file, "mod4");
        VehicleInfo[playerid][mod5] = dini_Int(file, "mod5");
        VehicleInfo[playerid][mod6] = dini_Int(file, "mod6");
        VehicleInfo[playerid][mod7] = dini_Int(file, "mod7");
        VehicleInfo[playerid][mod8] = dini_Int(file, "mod8");
        VehicleInfo[playerid][mod9] = dini_Int(file, "mod9");
        VehicleInfo[playerid][mod10] = dini_Int(file, "mod10");
        VehicleInfo[playerid][mod11] = dini_Int(file, "mod11");
        VehicleInfo[playerid][mod12] = dini_Int(file, "mod12");
        VehicleInfo[playerid][mod13] = dini_Int(file, "mod13");
        VehicleInfo[playerid][mod14] = dini_Int(file, "mod14");
        VehicleInfo[playerid][mod15] = dini_Int(file, "mod15");
        VehicleInfo[playerid][mod16] = dini_Int(file, "mod16");
        VehicleInfo[playerid][mod17] = dini_Int(file, "mod17");
        VehicleInfo[playerid][paintjob] = dini_Int(file, "paintjob");
        VehicleInfo[playerid][colora] = dini_Int(file, "color1");
        VehicleInfo[playerid][colorb] = dini_Int(file, "color2");
        Vehicle[playerid] = AddStaticVehicle(VehicleInfo[playerid][Model], VehicleInfo[playerid][CarX], VehicleInfo[playerid][CarY], VehicleInfo[playerid][CarZ], VehicleInfo[playerid][CarRot], VehicleInfo[playerid][colora], VehicleInfo[playerid][colorb]);
        if(VehicleInfo[playerid][mod1]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod1]); }
        if(VehicleInfo[playerid][mod2]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod2]); }
        if(VehicleInfo[playerid][mod3]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod3]); }
        if(VehicleInfo[playerid][mod4]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod4]); }
        if(VehicleInfo[playerid][mod5]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod5]); }
        if(VehicleInfo[playerid][mod6]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod6]); }
        if(VehicleInfo[playerid][mod7]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod7]); }
        if(VehicleInfo[playerid][mod8]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod8]); }
        if(VehicleInfo[playerid][mod9]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod9]); }
        if(VehicleInfo[playerid][mod10]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod10]); }
        if(VehicleInfo[playerid][mod11]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod11]); }
        if(VehicleInfo[playerid][mod12]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod12]); }
        if(VehicleInfo[playerid][mod13]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod13]); }
        if(VehicleInfo[playerid][mod14]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod14]); }
        if(VehicleInfo[playerid][mod15]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod15]); }
        if(VehicleInfo[playerid][mod16]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod16]); }
        if(VehicleInfo[playerid][mod17]!=0) { AddVehicleComponent(Vehicle[playerid],VehicleInfo[playerid][mod17]); }
        if(VehicleInfo[playerid][colora]!=0 || VehicleInfo[playerid][colorb]!=0)
        {
            ChangeVehicleColor(Vehicle[playerid],VehicleInfo[playerid][colora],VehicleInfo[playerid][colorb]);
        }
        if(VehicleInfo[playerid][paintjob]!=0)
        {
            ChangeVehiclePaintjob(Vehicle[playerid],VehicleInfo[playerid][paintjob]);
        }
       
        new tmp[256]; tmp = dini_Get(file, "Plate");
        gPlayerHasCar[playerid] = 1;
        VehOwned[Vehicle[playerid]] = 1;
        OwnerID[Vehicle[playerid]] = playerid;
        SetVehicleNumberPlate(Vehicle[playerid], tmp);
        VehPlate[Vehicle[playerid]] = tmp;
    }
    return 1;
}
But it wont load.. and in server console:


Код:
[debug] Run time error 4: "Array index out of bounds"
[debug]   Accessing element at index 65535 past array upper bound 1999
[debug] Backtrace:
[debug] #0  00006de0 in public OnPlayerConnect () from RiAuto.amx
Same onplayerdisconnect!!
Reply
#2

how did you define/declare+initialize Model, Price, CarX and so on?
that messages mean that you try to access an arrayindex (that stuff in []) that isn't declared.
this causes you to overwrite (more or less) random addresses in your memory.
Reply
#3

double post, write answers to:
https://sampforum.blast.hk/showthread.php?tid=337735
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)