What am i doing wrong
#1

Hello everyone
i am facing a little problem with my /vpark command

Код:
CMD:vpark(playerid, params[])
{
	new vid;
	if(PlayerInfo[playerid][pCar][0] == -1 && PlayerInfo[playerid][pCar][1] == -1 && PlayerInfo[playerid][pCar][2] == -1) return SendClientMessage(playerid, -1, "You cant use this command you dont own a vehicle!");
	if(IsPlayerInVehicle(playerid, OwnedVehicles[PlayerInfo[playerid][pCar][0]]))
	{
	    vid = PlayerInfo[playerid][pCar][0];
		SendClientMessage(playerid,0xFFFF00AA,"Vehicle Parked!");
		GetVehiclePos(OwnedVehicles[vid], VehicleInfo[vid][vPosX], VehicleInfo[vid][vPosY], VehicleInfo[vid][vPosZ]);
		GetVehicleZAngle(OwnedVehicles[vid], VehicleInfo[vid][vPosA]);
		return 1;
	}
	else if(IsPlayerInVehicle(playerid, OwnedVehicles[PlayerInfo[playerid][pCar][1]]))
	{
	    vid = PlayerInfo[playerid][pCar][1];
		SendClientMessage(playerid,0xFFFF00AA,"Vehicle Parked!");
		GetVehiclePos(OwnedVehicles[vid], VehicleInfo[vid][vPosX], VehicleInfo[vid][vPosY], VehicleInfo[vid][vPosZ]);
		GetVehicleZAngle(OwnedVehicles[vid], VehicleInfo[vid][vPosA]);
		return 1;
	}
	else if(IsPlayerInVehicle(playerid, OwnedVehicles[PlayerInfo[playerid][pCar][2]]))
	{
	    vid = PlayerInfo[playerid][pCar][2];
		SendClientMessage(playerid,0xFFFF00AA,"Vehicle Parked!");
		GetVehiclePos(OwnedVehicles[vid], VehicleInfo[vid][vPosX], VehicleInfo[vid][vPosY], VehicleInfo[vid][vPosZ]);
		GetVehicleZAngle(OwnedVehicles[vid], VehicleInfo[vid][vPosA]);
		return 1;
	}
	else
	{
		SendClientMessage(playerid, -1, "You must be inside your vehicle to park it!");
	}
	return 1;
}
the problem is if i have 3 cars /vpark works perfect but if i sell one car it gives me SERVER: UNKOWN COMMAND message i dont know whats wrong with my code ill be greatful if i get some help
Reply
#2

PHP код:
CMD:vparkplayeridparams[] ) {
    new 
vehicleid,
        
continue_;
    for( new 
i3i++ ) {
        if( 
IsPlayerInVehicleplayeridOwnedVehiclesPlayerInfoplayerid ][ pCar ][ ] ] ) ) {
            
continue_++;
            
vehicleid PlayerInfoplayerid ][ pCar ][ ];
            
GetVehiclePosOwnedVehiclesvehicleid ], VehicleInfovehicleid ][vPosX], VehicleInfovehicleid ][ vPosY ], VehicleInfovehicleid ][ vPosZ ] );
            
GetVehicleZAngleOwnedVehiclesvehicleid ], VehicleInfovehicleid ][ vPosA ] );
        }
    }
    if( 
continue_ ) {
        
SendClientMessageplayerid0xFFFF00AA"Vehicle Parked!" );
    } else {
        
SendClientMessageplayerid, -1"You must be inside your vehicle to park it!" );
    }
    return 
1;

Use a loop if you're going to use arrays!

Also use crashdetect and check your server_logs. See if an error occurred.
Reply
#3

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Use a loop if you're going to use arrays!

Also use crashdetect and check your server_logs. See if an error occurred.
Same issue this is the log:
Код:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 304 in array of size 250

[debug] AMX backtrace:
[debug] #0 00035e48 in ?? (0, 2, 1) from MyGM.amx
[debug] #1 00006134 in public OnPlayerStateChange (0, 2, 1) from MyGM.amx

[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at negative index -1
[debug] AMX backtrace:
[debug] #0 00060e74 in public cmd_vpark (0, 17815800) from MyGM.amx
[debug] #1 native CallLocalFunction () from samp-server.exe
[debug] #2 00010a5c in ?? (0, 17815772) from MyGM.amx
[debug] #3 00005bc0 in public OnPlayerCommandText (0, 17815772) from MyGM
.amx
Reply
#4

you also have something bad in
PHP код:
public OnPlayerStateChange 
and also
PHP код:
public OnPlayerCommandText 
Reply
#5

Create a file called pawn.cfg in Pawno folder

Type

Код:
-d3
inside it, save and then compile.

After that show the crash detect's log.
Reply
#6

i cant compile a .cfg file in pawno however i created the pawn.cfg with -d3 written inside but it still gives the same log

Код:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 304 in array of size 250

[debug] AMX backtrace:
[debug] #0 00035e48 in ?? (0, 2, 1) from MyGM.amx
[debug] #1 00006134 in public OnPlayerStateChange (0, 2, 1) from MyGM.amx

[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at negative index -1
[debug] AMX backtrace:
[debug] #0 00060f44 in public cmd_vpark (0, 17817200) from MyGM.amx
[debug] #1 native CallLocalFunction () from samp-server.exe
[debug] #2 00010a5c in ?? (0, 17817172) from MyGM.amx
[debug] #3 00005bc0 in public OnPlayerCommandText (0, 17817172) from MyGM
.amx
Reply
#7

When you compile your game mode, can you show me what output you get?
Reply
#8

yes i get this :

Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:          12020 bytes
Code size:           618896 bytes
Data size:         17817172 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:18464472 bytes
Reply
#9

Quote:
Originally Posted by TrueThing
Посмотреть сообщение
yes i get this :

Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:          12020 bytes
Code size:           618896 bytes
Data size:         17817172 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:18464472 bytes
Did you used some string or something bigger than 3072?

Example:

Код:
new String[4096];
Reply
#10

Using latest crashdetect? Because it should show error line for crash after this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)