Script problem
#1

Hey guys.
I create a teleport system with my own things but it seems like its not working.
I get no errors from script but when i try to start server it says "server crash while opening gamemode"
and if i delete my script server works well.

Here is my script.
Код HTML:
enum teleInfo
{
        tName[32],
        Float: tX,
        Float: tY,
        Float: tZ,
        Float: tA,
        tVW,
        tInt
};
new TeleInfo[MAX_TELES][teleInfo];

LoadTeleports()
{
        new string[128];
        new File: file = fopen("teleports/teleport%d.txt", io_read);
        new idx;
        while(idx < sizeof(TeleInfo) && fread(file, string))
        {
            sscanf(string, "p<|>s[32]ffffii",
            TeleInfo[idx][tName],
            TeleInfo[idx][tX],
            TeleInfo[idx][tY],
            TeleInfo[idx][tZ],
            TeleInfo[idx][tA],
            TeleInfo[idx][tVW],
            TeleInfo[idx][tInt]);
                ++idx;
        }
        return fclose(file);
}
SaveTeleports()
{
        new string[128];
        new File: file = fopen("teleports/teleport%d.txt", io_write);
        for(new i = 0; i < MAX_TELES; i++)
        {
            format(string, sizeof(string), "%s|%f|%f|%f|%f|%d|%d\r\n",
            TeleInfo[i][tName],
            TeleInfo[i][tX],
            TeleInfo[i][tY],
            TeleInfo[i][tZ],
            TeleInfo[i][tA],
            TeleInfo[i][tVW],
            TeleInfo[i][tInt]);
            fwrite(file, string);
        }
        return fclose(file);
}

// Stocks
stock GetFreeTeleSlot()
{
        for(new i = 0; i < MAX_TELES; i++)
        {
            if(strlen(TeleInfo[i][tName]) == 0) return i;
        }
        return -1;
}
COMMAND:createtele(playerid, params[])
{
        if(IsPlayerAdmin(playerid))
        {
            new name[32], string[128];
            new idx = GetFreeTeleSlot();
                if(sscanf(params, "s[32]", name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createtele [name]");

                GetPlayerPos(playerid, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ]);
                GetPlayerFacingAngle(playerid, TeleInfo[idx][tA]);
                TeleInfo[idx][tVW] = GetPlayerVirtualWorld(playerid);
                TeleInfo[idx][tInt] = GetPlayerInterior(playerid);
                strmid(TeleInfo[idx][tName], name, 0, strlen(name), 32);
                format(string, sizeof(string), "Teleport Created: [Name: %s | ID: %d | X: %.02f | Y: %.02f | Z: %.02f | A: %.02f | VW: %d | Int: %d]",
                TeleInfo[idx][tName], idx, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ], TeleInfo[idx][tA], TeleInfo[idx][tVW], TeleInfo[idx][tInt]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                SaveTeleports();
        }
        else
        {
            SendClientError(playerid,"ERROR: You are not authorized to use this command.");
        }
        return 1;
}
COMMAND:telename(playerid, params[])
{
        if(IsPlayerAdmin(playerid))
        {
            new idx, name[32], string[128];
            if(sscanf(params, "ds[32]", idx, name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /telename [teleid] [name]");

            if(strlen(TeleInfo[idx][tName]) == 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: That teleport doesn't exist.");

                new oldname[32];
                strmid(oldname, TeleInfo[idx][tName], 0, strlen(TeleInfo[idx][tName]), 32);
                strmid(TeleInfo[idx][tName], name, 0, strlen(name), 32);
                format(string, sizeof(string), "Teleport Name Edited: [ID: %d | Previous Name: %s | New Name: %s]",
                idx, oldname, TeleInfo[idx][tName]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                SaveTeleports();
        }
        else
        {
            SendClientError(playerid, "ERROR: You are not authorized to use this command.");
        }
        return 1;
}
COMMAND:destroytele(playerid, params[])
{
        if(IsPlayerAdmin(playerid))
        {
            new idx, string[128];
            if(sscanf(params, "d", idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /destroytele [teleid]");

            if(strlen(TeleInfo[idx][tName]) == 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: That teleport doesn't exist.");

                format(string, sizeof(string), "Teleport Destroyed: [ID: %d | Name: %s]",
                idx, TeleInfo[idx][tName]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                strdel(TeleInfo[idx][tName], 0, strlen(TeleInfo[idx][tName]));
                TeleInfo[idx][tX] = 0.0;
                TeleInfo[idx][tY] = 0.0;
                TeleInfo[idx][tZ] = 0.0;
                TeleInfo[idx][tA] = 0.0;
                TeleInfo[idx][tVW] = 0;
                TeleInfo[idx][tInt] = 0;
                SaveTeleports();
        }
        else
        {
            SendClientError(playerid, "ERROR: You are not authorized to use this command.");
        }
        return 1;
}
COMMAND:telepos(playerid, params[])
{
        if(IsPlayerAdmin(playerid))
        {
            new idx, string[128];
            if(sscanf(params, "d", idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /telepos [teleid]");

            if(strlen(TeleInfo[idx][tName]) == 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: That teleport doesn't exist.");

            GetPlayerPos(playerid, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ]);
            GetPlayerFacingAngle(playerid, TeleInfo[idx][tA]);
            TeleInfo[idx][tVW] = GetPlayerVirtualWorld(playerid);
            TeleInfo[idx][tInt] = GetPlayerInterior(playerid);
            format(string, sizeof(string), "Teleport Position Edited: [ID: %d | X: %.02f | Y: %.02f | Z: %.02f | A: %.02f | VW: %d | Int: %d]",
                idx, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ], TeleInfo[idx][tA], TeleInfo[idx][tVW], TeleInfo[idx][tInt]);
                SendClientMessage(playerid, COLOR_ORANGE, string);
                SaveTeleports();
        }
        else
        {
            SendClientError(playerid, "ERROR: You are not authorized to use this command.");
        }
        return 1;
}
COMMAND:teleport(playerid, params[])
{
        new idx, string[128];
        if(sscanf(params, "d", idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /teleport [teleid]");

        if(strlen(TeleInfo[idx][tName]) == 0) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: That teleport doesn't exist.");

        SetPlayerPos(playerid, TeleInfo[idx][tX], TeleInfo[idx][tY], TeleInfo[idx][tZ]);
        SetPlayerFacingAngle(playerid, TeleInfo[idx][tA]);
        SetPlayerVirtualWorld(playerid, TeleInfo[idx][tVW]);
        SetPlayerInterior(playerid, TeleInfo[idx][tInt]);
        format(string, sizeof(string), "Teleported to: %s [ID: %d | VW: %d | Int: %d]",
        TeleInfo[idx][tName], idx, TeleInfo[idx][tVW], TeleInfo[idx][tInt]);
        SendClientMessage(playerid, COLOR_ORANGE, string);
        return 1;
}
COMMAND:teles(playerid, params[])
{
        new string[128];
        SendClientMessage(playerid, COLOR_GREEN, "* Listing current teleports...");
        for(new i = 0; i < MAX_TELES; i++)
        {
                if(strlen(TeleInfo[i][tName]) != 0)
                {
                    format(string, sizeof(string), "Teleport %d: [Name: %s | VW: %d | Int: %d]",
                         i, TeleInfo[i][tName], TeleInfo[i][tVW], TeleInfo[i][tInt]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
        }
        return 1;
}
COMMAND:togglept(playerid, params[])
{
        if(IsPlayerAdmin(playerid))
        {
                new string[128];
                if(PLAYER_TELEPORTING == 0)
                {
                    PLAYER_TELEPORTING = 1;
                        format(string, sizeof(string), "zTeleports: %s has enabled player teleporting.", PlayerName(playerid));
                        SendClientMessageToAll(COLOR_WHITE, string);
                }
                else
                {
                        PLAYER_TELEPORTING = 0;
                        format(string, sizeof(string), "zTeleports: %s has disabled player teleporting.", PlayerName(playerid));
                        SendClientMessageToAll(COLOR_WHITE, string);
                }
        }
        else
        {
            SendClientError(playerid, "ERROR: You are not authorized to use this command.");
        }
        return 1;
}
Reply
#2

that teleport system reminds me of italy mafia's. nice sir.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)