command not executed and debug run time error 4
#1

pawn Код:
CMD:addvehicle(playerid,params[])
{
    if(!PlayerInfo[playerid][pScripter]) return SendClientMessage(playerid,COLOR_ERROR,ERROR_NOT_ADMIN);
    if(PlayerInfo[playerid][pSpawn])
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_ERROR,"You Need To Be In An Vehicle To Use This Command.");
        new string[256],Float:x,Float:y,Float:z,File:fhandle,type,modelid,Float:a;
        modelid = GetPlayerVehicleID(playerid);
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,a);
        if(sscanf(params,"d",type))type = 1;
        switch (type)
        {
            case 1:
            {
                format(string,sizeof(string),"CreateStaticVehicle(VEHICLE_TYPE_CIVILIAN,%d,%f,%f,%f,%f,-1,-1);\\ Location %s, Vehicle Name %s\r\n",modelid,x,y,z,a,PlayerInfo[playerid][pLocation],aVehicleNames[modelid - 400]);
            }
            case 2:
            {
                format(string,sizeof(string),"CreateStaticVehicle(VEHICLE_TYPE_DONATOR,%d,%f,%f,%f,%f,-1,-1);\\ Location %s, Vehicle Name %s\r\n",modelid,x,y,z,a,PlayerInfo[playerid][pLocation],aVehicleNames[modelid - 400]);
            }
            case 3:
            {
                format(string,sizeof(string),"CreateStaticVehicle(VEHICLE_TYPE_ADMIN,%d,%f,%f,%f,%f,-1,-1);\\ Location %s, Vehicle Name %s\r\n",modelid,x,y,z,a,PlayerInfo[playerid][pLocation],aVehicleNames[modelid - 400]);
            }
        }  
       
        if(fexist("ServerData/Vehicles.txt"))
        {
            fhandle = fopen("ServerData/Vehicles.txt",io_append);
            fwrite(fhandle,string);
            fclose(fhandle);
            print("[VEHICLE LOG DEBUG] File Exist");
        }
        else
        {
            fcreate("ServerData/Vehicles.txt");
            fhandle = fopen("ServerData/Vehicles.txt",io_write);
            fwrite(fhandle,string);
            fclose(fhandle);
            print("[VEHICLE LOG DEBUG] File Does Not Exist");
        }
        SendClientMessage(playerid,COLOR_ADMIN,"Vehicle Position Added.");
    } else SendClientMessage(playerid,COLOR_ERROR,ERROR_NOT_SPAWNED);
    return 1;
}
this is my command for adding vehicles
it doesn't get executed
i get this in log
Код:
[21:04:19] [debug] Run time error 4: "Array index out of bounds"
[21:04:19] [debug]  Accessing element at negative index -397
[21:04:19] [debug] AMX backtrace:
[21:04:19] [debug] #0 000a8264 in public cmd_addvehicle (0x00000000, 0x01654178) from 1v1.amx
[21:04:19] [debug] #1 native CallLocalFunction () [00472fc0] from samp-server.exe
[21:04:19] [debug] #2 00027eec in ?? (0x00000000, 0x01654148) from 1v1.amx
[21:04:19] [debug] #3 0000fac8 in public OnPlayerCommandText (0x00000000, 0x01654148) from 1v1.amx
if i am not in vehicle it send me the error
Код:
You Need To Be In An Vehicle To Use This Command.
but when i am i get that debug command is not executed
Reply
#2

Found the issue
Код:
        modelid = GetPlayerVehicleID(playerid);
Shouldnt it be GetVehicleModel(GetPlayerVehicleID(playerid));
Reply
#3

thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)