17.06.2012, 13:13
Hello,
This is weird. Values of arrays are changing, with proof.
As you see I create the vehicles here. This is the only place where I assign the value to the vehicles!!
Now when I check once for their value in OnPlayerStateChange...
As you see I added some debug lines. Debug says this
All fine and well, work good. Now when I enter it the second time;
The values have changed! I change them nowhere in the script, so how in hell can this happen? It also does not remove me from the vehicle anymore. Obviously because the the values changed.
Jochem
This is weird. Values of arrays are changing, with proof.
pawn Код:
LicenseVehicle[0] = AddStaticVehicleEx(426,211.9338,-140.8551,1.2101,179.5805,42,42,-1); // Car 1 [Premier]
LicenseVehicle[1] = AddStaticVehicleEx(426,201.8325,-141.0570,1.2098,180.4212,42,42,-1); // Car 2 [Premier]
LicenseVehicle[2] = AddStaticVehicleEx(426,194.1738,-140.9005,1.2133,359.6569,42,42,-1); // Car 3 [Premier]
LicenseVehicle[3] = AddStaticVehicleEx(454,-133.9991,-553.7247,0.1571,35.5402,26,26,-1); // Boat 1 [Tropic]
LicenseVehicle[4] = AddStaticVehicleEx(454,-161.5800,-579.4626,0.1670,35.6688,26,26,-1); // Boat 2 [Tropic]
LicenseVehicle[5] = AddStaticVehicleEx(515,-161.9176,-248.4982,2.4536,90.8201,54,77,-1); // Truck 1 [Roadtrain]
LicenseVehicle[6] = AddStaticVehicleEx(515,-161.2630,-237.1448,2.4465,90.4855,39,78,-1); // Truck 2 [Roadtrain]
Now when I check once for their value in OnPlayerStateChange...
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid),modelid = GetVehicleModel(vehicleid),string[128];
for(new v = 0; v < MAX_CARSHOPVEHS; v ++)
{
if(vehicleid == CarshopInfo[v][VehicleID])
{
format(string,sizeof(string),"~w~You can buy a ~y~%s ~w~for ~r~$%d~w~. Type ~b~/buyvehicle to ~w~purchase one!",vNames[modelid - 400],CarshopInfo[v][Price]);
SetInfoBoxMessage(playerid,string,5000);
SetPVarInt(playerid,"EngineDisabled",1);
return 1;
}
}
if(modelid != 509 && modelid != 510 && modelid != 481)
{
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleBoxDraw]);
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleNameDraw]);
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleSpeedDraw]);
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleFuelDraw]);
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleLightsDraw]);
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleDoorsDraw]);
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleTrunkDraw]);
TextDrawShowForPlayer(playerid,VehicleInfo[vehicleid][VehicleWindowsDraw]);
if(!VehicleInfo[vehicleid][EngineRunning]) SendClientMessage(playerid,COLOR_WHITE,"The engine is currently {FF0F0F}not running.");
else SendClientMessage(playerid,COLOR_WHITE,"The engine is currently {008000}running.");
SetPVarInt(playerid,"CurrentVehicle",vehicleid);
printf("vehicleid = %d - IsInLicTest = %d",vehicleid,GetPVarInt(playerid,"IsInLicTest"));
printf("LicenseVehicle 0 = %d",LicenseVehicle[0]);
printf("LicenseVehicle 1 = %d",LicenseVehicle[1]);
printf("LicenseVehicle 2 = %d",LicenseVehicle[2]);
if(vehicleid == LicenseVehicle[0] || vehicleid == LicenseVehicle[1] || vehicleid == LicenseVehicle[2])
{
if(GetPVarInt(playerid,"IsInLicTest") == 1)
{
GameTextForPlayer(playerid,"~r~Follow ~y~the ~b~Checkpoints ~g~in order! ~y~Do not ~b~damage ~r~the car!",4000,3);
SetPlayerRaceCheckpoint(playerid,0,150.499099,-139.523223,1.324658,-2004.248291,-57.189411,34.906349,3);
SetPVarInt(playerid,"RaceCheckpoint",1);
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_RED,"(( Error: You are not following the driving lessons. ))");
}
}
//.... The rest does not matter
Код:
[15:10:56] vehicleid = 1 - IsInLicTest = 0 [15:10:56] LicenseVehicle 0 = 1 [15:10:56] LicenseVehicle 1 = 2 [15:10:56] LicenseVehicle 2 = 3
Код:
[15:11:11] vehicleid = 1 - IsInLicTest = 0 [15:11:11] LicenseVehicle 0 = 100 [15:11:11] LicenseVehicle 1 = 44 [15:11:11] LicenseVehicle 2 = 32
Jochem