CreateDynamic3DTextLabel
#1

PHP код:
new labelstring[300];        
            new 
vehicleModel hVehicleData[playerid][i][ModelID];
            
            
format(labelstringsizeof(labelstring), "{58D3F7}[House Car] \n Name: %s \n Owner: %s"vehicleNames[vehicleModel 400], pname);
            
hVehicleData[playerid][i][hvLabel] = CreateDynamic3DTextLabel(labelstringCOLOR_WHITE0.00.01.215.0INVALID_PLAYER_IDhVehicleData[playerid][i][hVehicleID], 00, -1, -1); 
If i use that in my housecar system it gives me amx errors on player connect like this:

Код:
[09:27:27] [debug] Run time error 4: "Array index out of bounds"
[09:27:27] [debug]  Accessing element at negative index -400
[09:27:27] [debug] AMX backtrace:
[09:27:27] [debug] #0 000ae568 in ?? () from CnR1.amx
[09:27:27] [debug] #1 00180aa4 in ?? () from CnR1.amx
[09:27:27] [debug] #2 00038ff4 in public FC_OnPlayerConnect () from CnR1.amx
[09:27:27] [debug] #3 native CallLocalFunction () [004743b0] from samp-server.exe
[09:27:27] [debug] #4 000386a8 in ?? () from CnR1.amx
[09:27:27] [debug] #5 000188f4 in public MP_OPC () from CnR1.amx
[09:27:27] [debug] #6 native CallLocalFunction () [004743b0] from samp-server.exe
[09:27:27] [debug] #7 0001340c in ?? () from CnR1.amx
[09:27:27] [debug] #8 0000ab28 in ?? () from CnR1.amx
[09:27:27] [debug] #9 00008b98 in ?? () from CnR1.amx
[09:27:27] [debug] #10 00001288 in public OnPlayerConnect () from CnR1.amx
anywhere i went wrong?
Reply
#2

if your vehicleModel is 0 and you minus it with 400 result will be -400 so it will crash, check if vehiclemodel is valid before doing the label like how I've did below codes:
PHP код:
            new labelstring[300];
            new 
vehicleModel hVehicleData[playerid][i][ModelID];
            if(
vehicleModel// checks if vehicleModel value isn't 0
            
{
                
format(labelstringsizeof(labelstring), "{58D3F7}[House Car] \n Name: %s \n Owner: %s"vehicleNames[vehicleModel 400], pname);
                
hVehicleData[playerid][i][hvLabel] = CreateDynamic3DTextLabel(labelstringCOLOR_WHITE0.00.01.215.0INVALID_PLAYER_IDhVehicleData[playerid][i][hVehicleID], 00, -1, -1); 
            }
            else
            {
                
format(labelstringsizeof(labelstring), "{58D3F7}[House Car] \n Name: Null \n Owner: Null");
                
hVehicleData[playerid][i][hvLabel] = CreateDynamic3DTextLabel(labelstringCOLOR_WHITE0.00.01.215.0INVALID_PLAYER_IDhVehicleData[playerid][i][hVehicleID], 00, -1, -1); 
            } 
Reply
#3

PS: if i comment those lines no errors are given.
Reply
#4

hmm so do i have to check only if(vehmodel != 0) =
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)