Another bug
#1

Hi , yes it's me again , i need a small help on this because i always don't use crashdetect so i'am not experiant on this domain , my function didn't work and i have got an error

PHP код:

// After a truckdriver entered a checkpoint, a timer is created. This function is called when the timer runs out
public Trucker_LoadUnload(playerid)
{
    
// Check if the player is inside a convoy
    
if (APlayerData[playerid][InConvoy] == true)
    {
        
// If the player just loaded his goods at the loading-point
        
if (APlayerData[playerid][JobStep] == 1)
        {
            
APlayerData[playerid][JobStep] = 2// Set the next step of the convoy-job (wait until all members have loaded their cargo)
            
TextDrawSetString(APlayerData[playerid][MissionText], TXT_WaitingMembersToLoadCargo);
        }
        
// If the player just delivered his goods at the unloading-point
        
if (APlayerData[playerid][JobStep] == 3)
        {
            
APlayerData[playerid][JobStep] = 4// Set the next step of the convoy-job (wait until all members have unloaded their cargo)
            
TextDrawSetString(APlayerData[playerid][MissionText], TXT_WaitingMembersToUnLoadCargo);
        }
        
DisablePlayerCheckpoint(playerid); // Delete the loading/unloading-checkpoint
        
TogglePlayerControllable(playerid1); // Enable the player again (he can move again)
        
return 1// Don't allow the rest of the function to be executed
    
}
    
// If the player isn't inside a convoy, this part is executed
    // Check the JobStep
    
switch (APlayerData[playerid][JobStep])
    {
        case 
1// Player must load his goods
        
{
            
// Setup local variables
            
new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float:xFloat:yFloat:zUnloadMsg[100];
            
// Set JobStep to 2 (unloading goods)
            
APlayerData[playerid][JobStep] = 2;
            
// Delete the loading-checkpoint
            
DisablePlayerCheckpoint(playerid);
            
// Get the startlocation, endlocation and the load texts
            
format(StartLoc50ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
            
format(EndLoc50ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
            
format(Load50ALoads[APlayerData[playerid][LoadID]][LoadName]);
            
// Randomly set the load as overloaded (15% chance the load is overloaded)
            
Trucker_SetRandomOverloaded(playerid);
            
// Pre-format the missiontext (there may be some parts appended when overloaded/mafiaload
            
format(RouteText255TXT_HaulingCargoFromToDeliverLoadStartLocEndLoc);
            
// Check if the player is overloaded
            
if (APlayerData[playerid][Overloaded] == true)
            {
                
// Add "(OL)" to the missiontext to let the player know he's been overloaded
                
format(RouteText255"%s%s"RouteText" ~r~(OL)~w~");
                
// Send a message to the player to let him know he's been overloaded
                
SendClientMessage(playerid0xFFFFFFFFTXT_TruckerOverloaded);
            }
            
// Check if the player is carrying a mafia-load
            
if (ALoads[APlayerData[playerid][LoadID]][Mafia] == true)
            {
                
// Add "(ML)" to the missiontext to let the player know his load is wanted by the mafia
                
format(RouteText255"%s%s"RouteText" ~r~(ML)~w~");
                
// If the player is carrying a mafia-load, inform him about it
                
GameTextForPlayer(playeridTXT_TruckerMafiaInterested50004);
                
// Also set the data for the player to indicate he's carrying a mafiaload
                
APlayerData[playerid][MafiaLoad] = true;
                
// Also set the player's trailer ID (or the vehicle itself) as Mafia-load in the array "AVehicleMafiaLoad"
                
if (APlayerData[playerid][TrailerID] == 0)
                    
AVehicleData[APlayerData[playerid][VehicleID]][MafiaLoad] = true// The player has no trailer, so set his main vehicle as wanted by the mafia
                
else
                    
AVehicleData[APlayerData[playerid][TrailerID]][MafiaLoad] = true// The player has a trailer, so set his trailer as wanted by the mafia
            
}
            
// Set the TextDraw so the player can see it
            
TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
            
// Grab the x, y, z positions for the second location (to unload the goods)
            
ALocations[APlayerData[playerid][JobLoc2]][LocX];
            
ALocations[APlayerData[playerid][JobLoc2]][LocY];
            
ALocations[APlayerData[playerid][JobLoc2]][LocZ];
            
// Create a checkpoint where the player should unload the goods
            
SetPlayerCheckpoint(playeridxyz7);
            
// Inform the player that he must unload his goods
            
format(UnloadMsg100TXT_DeliverCargoToLoadEndLoc);
            
SendClientMessage(playerid0xFFFFFFFFUnloadMsg);
        }
        case 
2// Player is delivering his goods
        
{
            
// Setup local variables
            
new StartLoc[50], EndLoc[50], Load[50], Msg1[128], Msg2[128], Name[24], BonusMsg[128];
            
// Get the player name
            
GetPlayerName(playeridNamesizeof(Name));
            
// Get the startlocation, endlocation and the load texts
            
format(StartLoc50ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
            
format(EndLoc50ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
            
format(Load50ALoads[APlayerData[playerid][LoadID]][LoadName]);
            
// Construct the message sent to all players that this player completed a trucking mission
            
format(Msg1128TXT_PlayerCompletedTruckJobNameLoad);
            
format(Msg2128TXT_PlayerCompletedTruckJobInfoStartLocEndLoc);
            
SendClientMessageToAll(0xFFFFFFFFMsg1);
            
SendClientMessageToAll(0xFFFFFFFFMsg2);
            
// Setup local variables
            
new Float:x1Float:y1Float:x2Float:y2Float:DistanceMessage[128], PaymentBonus;
            
// Grab the x, y, z positions for the first location (to load the goods)
            
x1 ALocations[APlayerData[playerid][JobLoc1]][LocX];
            
y1 ALocations[APlayerData[playerid][JobLoc1]][LocY];
            
// Grab the x, y, z positions for the second location (to unload the goods)
            
x2 ALocations[APlayerData[playerid][JobLoc2]][LocX];
            
y2 ALocations[APlayerData[playerid][JobLoc2]][LocY];
            
// Calculate the distance between both points
            
Distance floatsqroot(((x2 x1) * (x2 x1)) + ((y2 y1) * (y2 y1)));
            
// Calculate the payment for the player
            
Payment floatround((Distance ALoads[APlayerData[playerid][LoadID]][PayPerUnit]), floatround_floor);
            
// Check if the player has done the bonus mission
            
if (RandomBonusMission[MissionFinished] == false)
            {
                
// Check all paramters (load, startlocation and end-location)
                
if (RandomBonusMission[RandomLoad] == APlayerData[playerid][LoadID])
                    if (
RandomBonusMission[RandomStartLoc] == APlayerData[playerid][JobLoc1])
                        if (
RandomBonusMission[RandomEndLoc] == APlayerData[playerid][JobLoc2])
                        {
                            
Payment Payment 2// Double the payment is the player was the first to do the bonus mission
                            
RandomBonusMission[MissionFinished] = true// Only one player can do the bonus mission, a new one is chosen next
                            
format(BonusMsg128"{00BBFF}Le joueur {FFBB00}%s{00BBFF} a terminй la mission bonus"Name);
                            
SendClientMessageToAll(0xFFFFFFFFBonusMsg);
                        }
            }
            
// Pay the player based on the distance between the loading-point and unloading-point
            
RewardPlayer(playeridPayment0);
            
PlayerExpTheirFaction(playerid);
            
// Send a message to let the player know he finished his mission and got paid
            
format(Message128TXT_RewardJobPayment);
            
SendClientMessage(playerid0xFFFFFFFFMessage);
            
// Add 40% bonus if the player has been overloaded
            
if (APlayerData[playerid][Overloaded] == true)
            {
                
// Calculate the bonus
                
Bonus = (Payment 40) / 100;
                
// Pay the bonus to the player
                
RewardPlayer(playeridBonus0);
                
// Send a message to let the player know he was overloaded and got paid
                
format(Message128TXT_TruckerBonusOverloadedBonus);
                
SendClientMessage(playerid0xFFFFFFFFMessage);
            }
            
// Add 65% bonus if the player has delivered a mafia load (mafia couldn't steal his load)
            
if (APlayerData[playerid][MafiaLoad] == true)
            {
                
// Calculate the bonus
                
Bonus = (Payment 65) / 100;
                
// Pay the bonus to the player
                
RewardPlayer(playeridBonus0);
                
// Send a message to let the player know he was overloaded and got paid
                
format(Message128TXT_TruckerBonusMafiaLoadBonus);
                
SendClientMessage(playerid0xFFFFFFFFMessage);
            }
            
// Add 15% bonus if the player has delivered the load with his own truck
            
if (AVehicleData[APlayerData[playerid][VehicleID]][Owned] == true)
            {
                
// Calculate the bonus
                
Bonus = (Payment 15) / 100;
                
// Pay the bonus to the player
                
RewardPlayer(playeridBonus0);
                
// Send a message to let the player know he was overloaded and got paid
                
format(Message128TXT_TruckerBonusOwnVehicleBonus);
                
SendClientMessage(playerid0xFFFFFFFFMessage);
            }
            
// Also add score-points to the score of the player based on the distance between the loading and unloading points
            
if (Distance 3000.0)
                
RewardPlayer(playerid02); // Distance is larger than 3000 units, so add 2 points
            
else
                
RewardPlayer(playerid01); // Distance is less than 3000 units, so add 1 point
            // Increase the stats for completing a trucking job
            
APlayerData[playerid][StatsTruckerJobs]++;
            
// Also save the data (in case the server crashes, progress would be lost)
            
PlayerFile_Save(playerid);
            
// End the current trucker job (clear mission-data)
            
Trucker_EndJob(playerid);
            
TogglePlayerControllable(playerid1);
        }
    }
    
// Enable the player again (he can move again)
    
TogglePlayerControllable(playerid1);
    return 
1;

PHP код:
[17:56:59] [debugRun time error 4"Array index out of bounds"
[17:56:59] [debug]  Accessing element at negative index -1
[17:56:59] [debugAMX backtrace:
[
17:56:59] [debug#0 005083bc in ?? (-1) from PPC_Trucking.amx
[17:56:59] [debug#1 00508924 in ?? (0) from PPC_Trucking.amx
[17:56:59] [debug#2 0048c674 in public Trucker_LoadUnload (0) from PPC_Trucking.amx 
Thank's for helping
PS: i'am using PPC gamemode
Reply
#2

I have the same problem for this callback for others jobs ( PPC_Trucking ).
Reply
#3

You must compile with -d3 flag so we can get what function is ?? and the exact lines: https://github.com/Zeex/samp-plugin-...ith-debug-info

Otherwise, it will be harder to find it as it's caused in one of these functions:
pawn Код:
Trucker_SetRandomOverloaded(playerid);
PlayerExpTheirFaction(playerid);
PlayerFile_Save(playerid);
Trucker_EndJob(playerid);
Reply
#4

i will make all this functions to a callbacks then i can get the error in Crashdetect is that true?

nvm , i will do the -d3 solution
Reply
#5

It might give the name of the public functions but I don't understand what's so hard with creating a pawn.cfg file into pawno folder and writing -d3 init.
Reply
#6

This is indeed a very common scripting problem that happens quite often it is easy to fix follow what Konstantinos says.
Reply
#7

Yes this is what i'am doing , anyway where can i get the result?

EDIT : this is the result when i compile

PHP код:
Header size:          14128 bytes
Code size
:          7032156 bytes
Data size
:         11142600 bytes
Stack
/heap size:     180000 bytesestimated maxusage=4081 cells (16324 bytes)
Total requirements:18368884 bytes 
Reply
#8

the bug comming from, i'am finding this with a manually methode ( remove the function and try ) and when i have remove this all work fine, and i'am remember that i have a problem with this system in this morning ( with -1 value ) , so how can i resolve this problem.

PHP код:
stock PlayerExpTheirFaction(playerid){
    new 
factionid APlayerData[playerid][Team];
    if(
factionid != -1)
    {
        
Factions[factionid][factionExp]++;
        
Factions[factionid][Coffre] += 100;
        return 
1;
    }
    
Faction_Save(factionid);
    return 
1;

pawn Код:
if(factionid != -1)
-1 = default faction value ( the player isn't in any faction ).
Reply
#9

now i'am confirm that

PHP код:
[19:34:32] [debug#0 00670048 in PlayerExpTheirFaction (playerid=0) at C:\Users\BLACK-~1\Desktop\MESGAM~1\RIVALS~3\pawno\include\Black_Entreprise.inc:183
[19:34:32] [debug#1 005cffd0 in public Trucker_LoadUnload (playerid=0) at C:\Users\BLACK-~1\Desktop\MESGAM~1\RIVALS~3\pawno\include\PPC_MissionsTrucking.inc:177 
first error

PHP код:
        Factions[factionid][factionExp]++; 
second error

PHP код:
            format(Message128TXT_RewardJobPayment); 
Reply
#10

It might be an invalid index but not -1. Change to:
pawn Код:
new factionid = APlayerData[playerid][Team];
if(!(0 <= factionid <= sizeof (Factions)))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)