SA-MP Forums Archive
Pawno crash while compile - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Pawno crash while compile (/showthread.php?tid=206647)



Pawno crash while compile - CoaPsyFactor - 04.01.2011

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;
}



Re: Pawno crash while compile - _rAped - 04.01.2011

This happens when you forget a } or a ;


Re: Pawno crash while compile - Sascha - 04.01.2011

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...


Re: Pawno crash while compile - Alex_Valde - 04.01.2011

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...


Re: Pawno crash while compile - _rAped - 04.01.2011

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)


Re: Pawno crash while compile - Toreno - 04.01.2011

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;
}