Run time Error 6: "Invalid Instruction"
#1



I'm not sure what caused this and what is causing it. I have checked every bit of code and nothing seems to be wrong. It only triggers when I move my ped around. I also don't have OnEnterExitModShop in my script, so I don't even know what's going on.
Reply
#2

Can you show me the server.exe more clearly?

Also that error happens usually when there is a missing bracket..
Reply
#3

You have a missing brace. Show us the code to help you fix it. Do you have OnEnterExitModShop in a filterscript ?
Reply
#4

I don't have a filterscript even active on my server, so it can't be that, and as for the code, here it is:

pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <YSI\y_ini>
//#include <streamer>
#include <foreach>

native WP_Hash(buffer[],len,const str[]);

main()
{
    print("Zombie Outbreak Roleplay Script");
    print("\n--------------------------------");
    print("Success");
}

enum pData
{
    Password[129],
    Level,
    XP,
    Admin,
    Kills,
    Deaths,
    Skin,
    Money
}

new Player[MAX_PLAYERS][pData];
// Global Variables

new Text:clocktd,
    Hour,
    Minute;

#define DIALOG_UNUSED 9999

#define DIALOG_REGISTER 1000
#define DIALOG_LOGIN 2000
#define DIALOG_SUCCESS_1 3000
#define DIALOG_SUCCESS_2 4000

#define QUIZ_0 9000
#define QUIZ_1 9001
#define QUIZ_2 9002
#define QUIZ_3 9003
#define QUIZ_RULES 9100

#define HOSTNAME "Zombie Outbreak Roleplay - Test"
#define VERSION "Alpha"
#define MAP "Las Venturas"
#define WEB "None"

#define PATH "Accounts/%s.ini"

#define WHITE 0xFFFFFFFF
#define BLACK 0x000000FF
#define GREY 0xC0C0C0FF
#define LIGHTRED 0xFF6347FF
#define RED 0xFF0000FF
#define GREEN 0x008000FF
#define ORANGE 0xFF8000FF
#define LIGHTBLUE 0x95DDFFFF
#define BLUE 0x0000FFFF
#define LIGHTPURPLE 0xC2A2DAFF
#define PURPLE 0xB685EBFF
#define YELLOW 0xFFFF00FF

#define WSKILL_0 WEAPONSKILL_PISTOL
#define WSKILL_1 WEAPONSKILL_PISTOL_SILENCED
#define WSKILL_2 WEAPONSKILL_DESERT_EAGLE
#define WSKILL_3 WEAPONSKILL_SHOTGUN
#define WSKILL_4 WEAPONSKILL_SAWNOFF_SHOTGUN
#define WSKILL_5 WEAPONSKILL_SPAS12_SHOTGUN
#define WSKILL_6 WEAPONSKILL_MICRO_UZI
#define WSKILL_7 WEAPONSKILL_MP5
#define WSKILL_8 WEAPONSKILL_AK47
#define WSKILL_9 WEAPONSKILL_M4
#define WSKILL_10 WEAPONSKILL_SNIPERRIFLE

// Stocks Start
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}

stock StatSaving(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "Account Data");
    INI_WriteInt(File, "Level", Player[playerid][Level]);
    INI_WriteInt(File, "XP", Player[playerid][XP]);
    INI_WriteInt(File, "Admin", Player[playerid][Admin]);
    INI_WriteInt(File, "Money", GetPlayerMoney(playerid));
    INI_WriteInt(File, "Kills", Player[playerid][Kills]);
    INI_WriteInt(File, "Deaths", Player[playerid][Deaths]);
    INI_Close(File);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH, playername);
    return string;
}

stock DefaultRegistrationVariables(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "Account Data");
    INI_WriteInt(File, "Level", 1);
    INI_WriteInt(File, "XP", 0);
    INI_WriteInt(File, "Money", 5);
    INI_WriteInt(File, "Admin", 0);
    INI_WriteInt(File, "Kills", 0);
    INI_WriteInt(File, "Deaths", 0);
    INI_Close(File);
    return 1;
}


stock LoadObjects()
{
    //Quiz Spawn
    CreateObject(19355, -2501.55371, -700.98651, 128.46049,   0.00000, -90.00000, 0.00000);
    CreateObject(19355, -2503.18872, -700.98541, 130.14461,   0.00000, 0.00000, 0.00000);
    CreateObject(19355, -2499.88477, -700.98541, 130.14461,   0.00000, 0.00000, 0.00000);
    CreateObject(19355, -2501.51367, -702.47968, 130.14461,   0.00000, 0.00000, 90.00000);
    CreateObject(19355, -2501.51367, -699.45569, 130.14461,   0.00000, 0.00000, 90.00000);
    CreateObject(19355, -2501.55371, -700.98651, 131.82050,   0.00000, -90.00000, 0.00000);
    return 1;
}

/*
stock RemoveObjects(playerid)
{
    //Crater Town
    RemoveBuildingForPlayer(playerid, 16303, 323.7734, 914.2578, 15.7891, 0.25);
    RemoveBuildingForPlayer(playerid, 16304, 353.5078, 832.4063, 21.7109, 0.25);
    RemoveBuildingForPlayer(playerid, 16302, 375.4453, 850.7500, 23.4297, 0.25);
    RemoveBuildingForPlayer(playerid, 16305, 390.5703, 875.8281, 24.0469, 0.25);
    RemoveBuildingForPlayer(playerid, 16481, 389.0391, 839.5000, 26.8906, 0.25);
    RemoveBuildingForPlayer(playerid, 16301, 419.0703, 814.7422, 18.4766, 0.25);
    RemoveBuildingForPlayer(playerid, 16318, 435.6719, 888.9141, -1.7656, 0.25);
    RemoveBuildingForPlayer(playerid, 16319, 444.3438, 899.5781, -8.1875, 0.25);
    RemoveBuildingForPlayer(playerid, 16316, 479.6094, 932.8203, -15.0703, 0.25);
    RemoveBuildingForPlayer(playerid, 16314, 485.0703, 809.4766, -2.7656, 0.25);
    RemoveBuildingForPlayer(playerid, 16081, 522.1563, 815.9453, 11.6797, 0.25);
    RemoveBuildingForPlayer(playerid, 16084, 526.5234, 885.4219, -44.3594, 0.25);
    RemoveBuildingForPlayer(playerid, 16446, 537.7344, 839.3984, -37.9844, 0.25);
    RemoveBuildingForPlayer(playerid, 16317, 486.0781, 938.5703, -19.8125, 0.25);
    RemoveBuildingForPlayer(playerid, 16324, 517.3906, 952.8047, -16.2891, 0.25);
    RemoveBuildingForPlayer(playerid, 16369, 529.9219, 971.6328, -13.1719, 0.25);
    RemoveBuildingForPlayer(playerid, 16082, 569.3281, 825.7969, -26.7734, 0.25);
    RemoveBuildingForPlayer(playerid, 16313, 569.0938, 825.2031, -31.0781, 0.25);
    RemoveBuildingForPlayer(playerid, 3398, 568.5391, 837.8906, -29.5156, 0.25);
    RemoveBuildingForPlayer(playerid, 16312, 589.5156, 828.7891, -32.8672, 0.25);
    RemoveBuildingForPlayer(playerid, 16315, 581.3047, 834.1250, -33.3984, 0.25);
    RemoveBuildingForPlayer(playerid, 3398, 601.4219, 814.6484, -30.4375, 0.25);
    RemoveBuildingForPlayer(playerid, 3398, 634.5234, 806.5625, -30.0547, 0.25);
    RemoveBuildingForPlayer(playerid, 16078, 662.8125, 833.6875, -39.3672, 0.25);
    RemoveBuildingForPlayer(playerid, 16080, 600.6328, 829.3594, -35.7344, 0.25);
    RemoveBuildingForPlayer(playerid, 16083, 602.2578, 829.7188, -41.8281, 0.25);
    RemoveBuildingForPlayer(playerid, 16079, 625.9141, 838.4141, -35.3359, 0.25);
    RemoveBuildingForPlayer(playerid, 16085, 627.8672, 850.2734, -42.7734, 0.25);
    RemoveBuildingForPlayer(playerid, 16071, 674.7734, 854.5156, -39.3672, 0.25);
    RemoveBuildingForPlayer(playerid, 3214, 676.5859, 827.3281, -35.3672, 0.25);
    RemoveBuildingForPlayer(playerid, 3398, 668.3672, 815.2422, -30.1172, 0.25);
    RemoveBuildingForPlayer(playerid, 3214, 687.6250, 847.1094, -35.3828, 0.25);
    RemoveBuildingForPlayer(playerid, 3398, 684.2031, 835.6563, -30.8984, 0.25);
    RemoveBuildingForPlayer(playerid, 16075, 568.5234, 916.3438, -35.3359, 0.25);
    RemoveBuildingForPlayer(playerid, 16309, 566.6484, 874.4844, -39.5313, 0.25);
    RemoveBuildingForPlayer(playerid, 3398, 576.1563, 934.9219, -30.0938, 0.25);
    RemoveBuildingForPlayer(playerid, 16310, 581.3750, 875.6094, -43.9609, 0.25);
    RemoveBuildingForPlayer(playerid, 16311, 585.8438, 869.6328, -39.3672, 0.25);
    RemoveBuildingForPlayer(playerid, 16325, 590.2969, 870.2734, -44.2656, 0.25);
    RemoveBuildingForPlayer(playerid, 16073, 610.1641, 908.4766, -39.3672, 0.25);
    RemoveBuildingForPlayer(playerid, 16074, 605.0859, 902.1563, -39.3672, 0.25);
    RemoveBuildingForPlayer(playerid, 16077, 594.9297, 926.4141, -41.1953, 0.25);
    RemoveBuildingForPlayer(playerid, 16076, 623.3047, 893.7734, -39.7656, 0.25);
    RemoveBuildingForPlayer(playerid, 3398, 620.8359, 884.2422, -29.5156, 0.25);
    RemoveBuildingForPlayer(playerid, 16072, 640.3125, 874.7891, -35.3359, 0.25);
    RemoveBuildingForPlayer(playerid, 16334, 709.4453, 915.9297, 34.6172, 0.25);
    RemoveBuildingForPlayer(playerid, 16337, 713.8047, 906.8125, -19.9141, 0.25);
   
    //Town 2
    RemoveBuildingForPlayer(playerid, 16403, -795.9297, 2395.0781, 153.6094, 0.25);
    RemoveBuildingForPlayer(playerid, 3275, -812.0547, 2406.4531, 155.9688, 0.25);
    RemoveBuildingForPlayer(playerid, 3275, -775.9922, 2408.3594, 156.8281, 0.25);
    RemoveBuildingForPlayer(playerid, 3350, -773.0391, 2419.6484, 155.9688, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -774.2266, 2421.2656, 157.0313, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -775.1953, 2424.9609, 157.0313, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -774.2031, 2425.3672, 159.2969, 0.25);
    RemoveBuildingForPlayer(playerid, 16404, -772.1641, 2424.2031, 157.9219, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -772.2734, 2422.0234, 159.5781, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -772.2578, 2425.3828, 159.3750, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -770.2422, 2421.2656, 157.0313, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -769.1563, 2424.7656, 157.0313, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -770.3359, 2422.0234, 159.5313, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -808.5469, 2428.9375, 159.2109, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -812.3281, 2428.1406, 159.3750, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -810.0859, 2426.1797, 156.8672, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -813.0859, 2428.2891, 156.8672, 0.25);
    RemoveBuildingForPlayer(playerid, 16405, -809.6953, 2429.2188, 157.7656, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -771.5547, 2425.9609, 157.0313, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -773.7500, 2426.0938, 157.0391, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -807.4063, 2430.1328, 156.8828, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -807.9609, 2430.7891, 159.1406, 0.25);
    RemoveBuildingForPlayer(playerid, 3302, -811.7344, 2429.9922, 159.4219, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -808.0391, 2431.8672, 156.8672, 0.25);
    RemoveBuildingForPlayer(playerid, 3260, -811.8516, 2432.0781, 156.8672, 0.25);
   
    //SCP Area 51
    RemoveBuildingForPlayer(playerid, 3387, 284.8828, 1834.4844, 7.0391, 0.25);
    RemoveBuildingForPlayer(playerid, 3383, 289.8594, 1830.6953, 7.0391, 0.25);
    RemoveBuildingForPlayer(playerid, 3393, 291.7266, 1835.4375, 7.0313, 0.25);
    RemoveBuildingForPlayer(playerid, 3390, 311.5781, 1827.1875, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 3391, 306.7891, 1827.1875, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 16655, 307.0391, 1837.7813, 8.6250, 0.25);
    RemoveBuildingForPlayer(playerid, 3392, 319.4531, 1827.1797, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 3383, 314.0781, 1832.1641, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 3384, 319.5234, 1844.8594, 6.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 3384, 320.7578, 1844.8594, 6.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 3387, 324.1797, 1847.7422, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 3388, 324.1797, 1846.3750, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 3389, 324.1797, 1850.4922, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 3393, 326.4609, 1827.1797, 4.8359, 0.25);
    RemoveBuildingForPlayer(playerid, 3383, 321.8047, 1832.1641, 4.8359, 0.25);
   
//------------------------Interiors-----------------------------------------

    //Gas Station - Fort Carson
    RemoveBuildingForPlayer(playerid, 14604, 1492.9766, 1303.8516, 1093.2656, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1491.0078, 1304.1406, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1490.3203, 1304.1406, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 950, 1502.6094, 1304.2813, 1092.8203, 0.25);
    RemoveBuildingForPlayer(playerid, 2164, 1487.7266, 1305.0391, 1092.2734, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1498.1406, 1305.1328, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1499.6484, 1305.1328, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1501.0781, 1305.1328, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1489.7656, 1306.0234, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1489.0078, 1306.2188, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 2173, 1489.4688, 1306.2578, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 2190, 1489.8984, 1306.4141, 1093.0781, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1498.1406, 1305.7813, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1498.1406, 1306.4141, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1499.6484, 1305.7813, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1499.6484, 1306.4141, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1501.0781, 1305.7813, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1501.0781, 1306.4141, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 2202, 1488.1953, 1307.2109, 1092.2734, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1491.1719, 1307.8906, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 2190, 1491.5000, 1308.3047, 1093.0781, 0.25);
    RemoveBuildingForPlayer(playerid, 2173, 1491.5625, 1308.5313, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1491.2266, 1309.1328, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 949, 1488.3750, 1309.4063, 1092.9141, 0.25);
    RemoveBuildingForPlayer(playerid, 2163, 1489.4297, 1309.9219, 1092.2734, 0.25);
    RemoveBuildingForPlayer(playerid, 2162, 1489.4922, 1309.9297, 1093.8203, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1498.1406, 1307.0156, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1498.1406, 1307.6719, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1499.6484, 1307.0156, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1499.6484, 1307.6719, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1501.0781, 1307.0156, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 1721, 1501.0781, 1307.6719, 1092.2813, 0.25);
    RemoveBuildingForPlayer(playerid, 950, 1502.6094, 1309.3828, 1092.8203, 0.25);

    return 1;
}

stock LoadPickups()
{
    return 1;
}

stock LoadTextDraws()
{
    return 1;
}
*/


stock SendLocalMessage(playerid, color, string[])
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    foreach(Player, i)
    {
        if(IsPlayerConnected(i) && GetPVarInt(i, "LoggedIn") == 1)
        {
            if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i) && GetPlayerInterior(playerid) == GetPlayerInterior(i))
            {
                if(IsPlayerInRangeOfPoint(i, 20, x, y, z))
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    }
    return 1;
}

stock SendShoutMessage(playerid, color, string[])
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    foreach(Player, i)
    {
        if(IsPlayerConnected(i) && GetPVarInt(i, "LoggedIn") == 1)
        {
            if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i) && GetPlayerInterior(playerid) == GetPlayerInterior(i))
            {
                if(IsPlayerInRangeOfPoint(i, 40, x, y, z))
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    }
    return 1;
}
stock SendLowMessage(playerid, color, string[])
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    foreach(Player, i)
    {
        if(IsPlayerConnected(i) && GetPVarInt(i, "LoggedIn") == 1)
        {
            if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i) && GetPlayerInterior(playerid) == GetPlayerInterior(i))
            {
                if(IsPlayerInRangeOfPoint(i, 7, x, y, z))
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    }
    return 1;
}

/*
stock pName(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
*/


// Stocks End

// Forward/Public Start

forward ClockUpdate();
public ClockUpdate()
{
    new string[25];
    //new str[128];
    Minute++;
    if(Minute==60)
    {
        Hour++;
        if(Hour == 24)
        {
            Hour=0;
        }
        Minute=0;
        /*
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                Player[i][XP] ++;
                format(str, sizeof(str), "{FFFFFF}You have earned {00FF00}1 experience point. {FFFFFF}New total: {00FF00}%d.", Player[i][XP]);
                SendClientMessage(i, WHITE, str);
            }
        }
        */

    }
    format(string, sizeof(string), "%02i:%02i", Hour, Minute);
    TextDrawSetString(clocktd, string);
    SetWorldTime(Hour);
    return 1;
}

forward LoginDelay(playerid);
public LoginDelay(playerid)
{
    new id;
    TogglePlayerControllable(id, 1);
    return 1;
}

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Password",Player[playerid][Password],129);
    INI_Int("Level", Player[playerid][Level]);
    INI_Int("XP", Player[playerid][XP]);
    INI_Int("Money",Player[playerid][Money]);
    INI_Int("Admin",Player[playerid][Admin]);
    INI_Int("Kills",Player[playerid][Kills]);
    INI_Int("Deaths",Player[playerid][Deaths]);
    return 1;
}

forward KickTimer();
public KickTimer()
{
    new id;
    Kick(id);
    return 1;
}

/* Forward/Public End */

public OnGameModeInit()
{
    //LoadObjects();
    DisableInteriorEnterExits();
    ManualVehicleEngineAndLights();
    //LoadTextDraws();
    //LoadPickups();
    SendRconCommand("hostname "HOSTNAME"");
    SendRconCommand("mapname "MAP"");
    SendRconCommand("weburl "WEB"");
    SetGameModeText("ZO-RP: "VERSION"");
    Hour = 12;
    Minute = 30;
    SetTimer("ClockUpdate", 60000, true);
    AddPlayerClass(1, -2501.7244, -700.9158, 129.5464, 268.2668, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        Player[killerid][Kills]++;
        Player[playerid][Deaths]++;
    }
    else
    {
        Player[playerid][Deaths]++;
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    //RemoveObjects(playerid);
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, QUIZ_0, DIALOG_STYLE_MSGBOX, "Welcome", "Hello!  It seems this is your first time on the server!\nBefore you register your account, you need to take a quiz to ensure you are capable of roleplay.\nPlease hit 'Start' to begin the quiz!", "Start", "Quit");
        //ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Register","Type a password below to register a new account.","Register","Quit");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register","You have entered an invalid password.\nType a valid password below to register a new account.","Register","Quit");
                new hashpass[129];
                WP_Hash(hashpass,sizeof(hashpass),inputtext);
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File, "Account Data");
                INI_WriteString(File, "Password", hashpass);
                INI_WriteInt(File, "Level", 1);
                INI_WriteInt(File, "XP", 0);
                INI_WriteInt(File, "Admin", 0);
                INI_WriteInt(File, "Money", 5);
                INI_WriteInt(File, "Kills", 0);
                INI_WriteInt(File, "Deaths", 0);
                INI_Close(File);
                SendClientMessage(playerid, YELLOW, "You have successfully registered your account, please reconnect to login and start playing.");
                SetTimerEx("KickTimer", 1000, false, "i", playerid);
            }
        }
        case DIALOG_LOGIN:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                new hashpass[129];
                WP_Hash(hashpass,sizeof(hashpass),inputtext);
                if(!strcmp(hashpass,Player[playerid][Password]))
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    SetPlayerScore(playerid, Player[playerid][Level]);
                    GivePlayerMoney(playerid, Player[playerid][Money]);
                    SetPVarInt(playerid, "LoggedIn", 1);
                    SetTimerEx("LoginDelay", 2000, false, "i", playerid);
                    SetSpawnInfo(playerid, 0, 1, 62.2422, 1217.1779, 18.8384, 178.8550, 0, 0, 0, 0, 0, 0);
                    GameTextForPlayer(playerid, "Loading...", 2000, 5);
                    SendClientMessage(playerid, WHITE, "You have {00FF00}successfully {FFFFFF}logged in.");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","You have entered an {FF0000}incorrect {FFFFFF}password.\nType your password below to login.","Login","Quit");
                }
            }
        }
        case QUIZ_0:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                ShowPlayerDialog(playerid, QUIZ_1, DIALOG_STYLE_LIST, "Question 1 - What is roleplay?", "A - Rolling around the ground\nB - Playing with a ball\nC - Taking the role of a person", "Select", "Quit");
            }
        }
        case QUIZ_1:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(listitem == 0)
                {
                    SendClientMessage(playerid, RED, "You have choosen the wrong answer and failed the quiz.");
                    SetTimerEx("KickTimer", 100, false, "i", playerid);
                }
                if(listitem == 1)
                {
                    SendClientMessage(playerid, RED, "You have choosen the wrong answer and failed the quiz.");
                    SetTimerEx("KickTimer", 100, false, "i", playerid);
                }
                if(listitem == 2)
                {
                    SendClientMessage(playerid, GREEN, "Correct!");
                    ShowPlayerDialog(playerid, QUIZ_2, DIALOG_STYLE_LIST, "Question 2 - What is metagaming (MG)?", "A - Using In Character (IC) information Out of Character (OOC)\nB - Using Out of Character (OOC) information In Character (IC)\nC - Saying the word 'meta' while playing a game", "Select", "Quit");
                }
            }
        }
        case QUIZ_2:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(listitem == 0)
                {
                    SendClientMessage(playerid, RED, "You have choosen the wrong answer and failed the quiz.");
                    SetTimerEx("KickTimer", 100, false, "i", playerid);
                }
                if(listitem == 1)
                {
                    SendClientMessage(playerid, GREEN, "Correct!");
                    ShowPlayerDialog(playerid, QUIZ_3, DIALOG_STYLE_LIST, "Question 3 - What is powergaming (PG)?", "A - Using batteries or some sort of energy to power a game\nB - Forcing roleplay apon others without giving them a chance to roleplay back\nC - Using a powered weapon to kill everyone", "Select", "Quit");
                }
                if(listitem == 2)
                {
                    SendClientMessage(playerid, RED, "You have choosen the wrong answer and failed the quiz.");
                    SetTimerEx("KickTimer", 100, false, "i", playerid);
                }
            }
        }
        case QUIZ_3:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(listitem == 0)
                {
                    SendClientMessage(playerid, RED, "You have choosen the wrong answer and failed the quiz.");
                    SetTimerEx("KickTimer", 100, false, "i", playerid);
                }
                if(listitem == 1)
                {
                    SendClientMessage(playerid, GREEN, "Correct!");
                    ShowPlayerDialog(playerid, QUIZ_RULES, DIALOG_STYLE_MSGBOX, "End of quiz", "Do you understand and agree that if you are to break any of the server rules you could be a-jailed, kicked, or banned from the server?", "Yes", "No");
                }
                if(listitem == 2)
                {
                    SendClientMessage(playerid, RED, "You have choosen the wrong answer and failed the quiz.");
                    SetTimerEx("KickTimer", 100, false, "i", playerid);
                }
            }
        }
        case QUIZ_RULES:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Register","Type a password below to register a new account.","Register","Quit");
            }
        }
    }
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(fexist(UserPath(playerid)))
    {
        StatSaving(playerid);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
        new string[128];
        format(string, sizeof(string), "The command {FF0000}%s {C0C0C0}does not exist, please use /help.", cmdtext);
        SendClientMessage(playerid, GREY, string);
    }
    return 1;
}

public OnPlayerText(playerid, text[])
{
    new message[128];
    format(message, sizeof(message), "%s says: %s", GetName(playerid), text);
    SendLocalMessage(playerid, WHITE, message);
    return 0;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    if(GetPlayerMoney(playerid) != Player[playerid][Money])
    {
        ResetPlayerMoney(playerid);
        GivePlayerMoney(playerid, Player[playerid][Money]);
    }

    SetPlayerScore(playerid, Player[playerid][Level]);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SpawnPlayer(playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)