03.01.2015, 19:14
(
Последний раз редактировалось Aasim; 04.01.2015 в 00:04.
)
Hello, I've been trying to fix this bug for quite a while now, logged it and I still can't figure out why it is happening.
So for some reason, the variable I use to store the player's vehicle is assigning vehicle id's that already are in use.
First of all, here's the code:
Since the code for /v is too long because it's on a dialog I will put it in an external paste.
Here: http://pastebin.com/4BiivVHz
Here is some logging I did: https://ghostbin.com/paste/3euqs
Notes: as you can see at [19:03:24] the variable is reseted for playerid 26... then... at [19:03:33] playerid 18 also resets BUT gets the same vehicleid as 26
Please notice that in that log, when you don't see a INVALID_VEHICLE_ID before a [SPAWN] it's because that vehicle is the first one he spawns.
This is how I did the logging: https://ghostbin.com/paste/tn78p
No filterscripts(I unloaded all to test) are causing this problem, this code is from my gamemode.
The plugins I'm using are: crashdetect.so[Version: v4.14] streamer.so [Version: v2.7.4] mysql.so [Version: R38] sscanf.so [Version: 2.8.1] mysql_static.so [Version: R38] (this plugin is the actual one being used, the other fails to load, gotta delete one of them, forgot..)
Thank you for your attention.
So for some reason, the variable I use to store the player's vehicle is assigning vehicle id's that already are in use.
First of all, here's the code:
Код:
CMD:car(playerid, params[]) { if(GetPlayerVirtualWorld(playerid) == 1520 || GetPlayerVirtualWorld(playerid) == 1517 || GetPlayerVirtualWorld(playerid) == 1331) return SendClientMessage(playerid, COLOR_GREY, "You can't use that cmd in this zone!"); new Vehicle[32], VehicleID, ColorOne, ColorTwo; if(sscanf(params, "s[32]D(1)D(1)", Vehicle, ColorOne, ColorTwo)) { SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /car [Vehiclename/Vehicleid] [Color 1 (optional)] [Color 2 (optional)]"); SendClientMessage(playerid, COLOR_GREY, "[USAGE]: Like /car Turismo , /car Elegy /car Nrg /car 522"); return 1; } if(strcmp(Vehicle, "520")==0 || strcmp(Vehicle, "425")==0 || strcmp(Vehicle, "432")==0 || strcmp(Vehicle, "464")==0 || strcmp(Vehicle, "476")==0 && GetPlayerVirtualWorld(playerid) == 0) return SendClientMessage(playerid, COLOR_GREY, "War vechiles are not allowed in fun zone."); VehicleID = GetVehicleModelIDFromName(Vehicle); if(VehicleID != 425 && VehicleID != 432 && VehicleID != 447 && VehicleID != 430 && VehicleID != 417 && VehicleID != 435 && VehicleID != 446 && VehicleID != 449 && VehicleID != 450 && VehicleID != 452 && VehicleID != 453 && VehicleID != 454 && VehicleID != 460 && VehicleID != 464 && VehicleID != 465 && VehicleID != 469 && VehicleID != 472 && VehicleID != 473 && VehicleID != 476 && VehicleID != 484 && VehicleID != 487 && VehicleID != 488 && VehicleID != 493 && VehicleID != 497 && VehicleID != 501 && VehicleID != 511 && VehicleID != 512 && VehicleID != 513 && VehicleID != 519 && VehicleID != 520 && VehicleID != 537 && VehicleID != 538 && VehicleID != 548 && VehicleID != 553 && VehicleID != 563 && VehicleID != 564 && VehicleID != 569 && VehicleID != 570 && VehicleID != 577 && VehicleID != 584 && VehicleID != 590 && VehicleID != 591 && VehicleID != 592 && VehicleID != 593 && VehicleID != 594 && VehicleID != 595 && VehicleID != 606 && VehicleID != 607 && VehicleID != 608 && VehicleID != 610 && VehicleID != 611) { if(VehicleID == -1 ) { VehicleID = strval(Vehicle); if(VehicleID < 400 || VehicleID > 611 ) { return SendClientMessage(playerid, COLOR_GREY, "You entered an invalid vehiclename!"); } } SpawnPlayerVehicle(playerid, VehicleID, ColorOne, ColorTwo); SendClientMessage(playerid, COLOR_GREY, "You succesfully spawned this vehicle!"); } else SendClientMessage(playerid, COLOR_GREY, "War vechiles are not allowed in fun zone."); return 1; } stock DestroyPlayerVehicle(playerid) { if (Veh[playerid] != INVALID_VEHICLE_ID) { DestroyVehicle(Veh[playerid]); Veh[playerid] = INVALID_VEHICLE_ID; printf("[SPAWN] Player %d vehicleid: INVALID_VEHICLE_ID", playerid); return true; } return false; } DestroyPlayerVehicleByVehicleID(vehicleid) { for (new i; i < MAX_PLAYERS; i++) { if (Veh[i] == vehicleid) { DestroyPlayerVehicle(i); } } } stock SpawnPlayerVehicle(playerid, modelid, Color1, Color2, bool:destroyOld = true) { if (destroyOld) { DestroyPlayerVehicle(playerid); } GetPlayerPos(playerid, pX, pY, pZ); GetPlayerFacingAngle(playerid, pAngle); Veh[playerid] = CreateVehicle(modelid, pX, pY, pZ+2.0, pAngle, Color1, Color2, -1); LinkVehicleToInterior(Veh[playerid], GetPlayerInterior(playerid)); SetVehicleVirtualWorld(Veh[playerid], GetPlayerVirtualWorld(playerid)); PutPlayerInVehicle(playerid, Veh[playerid], 0); printf("[SPAWN] Player %d vehicleid: %d", playerid, Veh[playerid]); //checkbug(playerid, "SpawnPlayerVehicle"); } CMD:v(playerid, params[]) { //printf("ID: %d VALUE:%d",playerid,Veh[playerid]); if(GetPlayerVirtualWorld(playerid) == 1520 || GetPlayerVirtualWorld(playerid) == 1517 || GetPlayerVirtualWorld(playerid) == 1331) return SendClientMessage(playerid, COLOR_GREY, "You can't use that cmd in this zone!"); new allvehicles[] = "1\tAirplanes\n2\tHelicopters\n3\tBikes\n4\tConvertibles\n5\tIndustrial\n6\tLowriders\n7\tOffRoad\n8\tPublic Service Vehicles\n9\tSaloons\n10\tSport Vehicles\n11\tStation Wagons\n12\tBoats\n13\tUnique Vehicles\n14\tRC Vehicles\n15\tTrailers"; ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST," Vehicles: || Scroll Down for more",allvehicles,"Select","Cancel"); return 1; } public OnPlayerDisconnect(playerid, reason) { DestroyPlayerVehicle(playerid); return 1; } public OnVehicleDeath(vehicleid, killerid) { if(killerid == INVALID_PLAYER_ID) DestroyPlayerVehicleByVehicleID(vehicleid); return 1; }
Here: http://pastebin.com/4BiivVHz
Here is some logging I did: https://ghostbin.com/paste/3euqs
Notes: as you can see at [19:03:24] the variable is reseted for playerid 26... then... at [19:03:33] playerid 18 also resets BUT gets the same vehicleid as 26
Please notice that in that log, when you don't see a INVALID_VEHICLE_ID before a [SPAWN] it's because that vehicle is the first one he spawns.
This is how I did the logging: https://ghostbin.com/paste/tn78p
No filterscripts(I unloaded all to test) are causing this problem, this code is from my gamemode.
The plugins I'm using are: crashdetect.so[Version: v4.14] streamer.so [Version: v2.7.4] mysql.so [Version: R38] sscanf.so [Version: 2.8.1] mysql_static.so [Version: R38] (this plugin is the actual one being used, the other fails to load, gotta delete one of them, forgot..)
Thank you for your attention.