Pawno crash while compile
#1

Hi there,

I have some serious problem, when i try to compile some code, and i use fopen, fwrite etc.
Pawno simply crashes


Here is code that I'm trying to compile:
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

new Float:x, Float:y, Float:z, Float:a;

forward CreateVehicle(playerid, vehicleid, color_1, color_2);

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public CreateVehicle(playerid, vehicleid, color_1, color_2){
    new VehicleParams[512];
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    CreateVehicle(vehicleid, x, y, z, a, color_1, color_2, 900);
    format(VehicleParams, sizeof(VehicleParams), "%d,%d,%d,%f,%f,%f,%f\r\n", vehicleid, color_1, color_2, x, y, z, a);
    new File:CreateVehicle = fopen("vehicles.txt", io_append);
    fwrite(CreateVehicle, VehicleParams);
    fclose(CreateVehicle);
    return 1;
}
Reply
#2

This happens when you forget a } or a ;
Reply
#3

normally not raped, at least not for me...
when I forget a } or so it just returns many errors, however it doesn't crash for me...
I guess it's the CreateVehicle function...
CreateVehicle is already defined by a_samp.inc and the way you are using it does not fit to it at all... rename it and try it again...
Reply
#4

Nah, nah, I don't think it's that. It's 'cause you made an CreateVehicle as a public, and CreateVehicle is a function so it can't be as a public.

Try to rename CreateVehicle to MakeVehicle or something like that...
Reply
#5

Yeah but when the pawno editor gets too many errors, it will crash. And is usually caused by a } or something missing, but in this case I oversaw that. You made a public that already exists. (@Alex Valde)
Reply
#6

You did a stupid mistake, first... you can't rechange a function that is already exist.
You did a new forward which is CreateVehicle and there is already such function as this.
Here you go, a fixed script:
pawn Код:
#include <a_samp>

new Float:x, Float:y, Float:z, Float:a;
forward CreateVeh(playerid, vehicleid, color_1, color_2);

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public CreateVeh(playerid, vehicleid, color_1, color_2)
{
    new VehicleParams[512];
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    CreateVehicle(vehicleid, x, y, z, a, color_1, color_2, 900);
    format(VehicleParams, sizeof(VehicleParams), "%d,%d,%d,%f,%f,%f,%f\r\n", vehicleid, color_1, color_2, x, y, z, a);
    new File: file = fopen("vehicles.txt", io_append);
    fwrite(file, VehicleParams);
    fclose(file);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)