SA-MP Forums Archive
Register System - 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: Register System (/showthread.php?tid=264458)



Register System - Max_Coldheart - 26.06.2011

Okay so I'm getting few errors while making my register system. This is the script:
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>
#include <zcmd>
#include <sscanf2>

new gTeam[MAX_PLAYERS];//its an array

enum pInfo
{
    pAdminLevel,
    pRegistered,
    pLogged,
    pScore,
    pCookies,
    pCash
}
new PlayerInfo[MAX_PLAYERS][pInfo];

//-------[COLOR CODES]------
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_BRIGHTRED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_BLUE 0x3A47DEFF
#define COLOR_TAN 0xBDB76BAA
#define COLOR_PURPLE 0x800080AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_BLACK 0x00000000
#define COLOR_DARKGREY 0x696969FF

//-----[DIALOGS]------
#define REGISTER_DIALOG 23
#define LOGIN_DIALOG 25


//User Path
#define USER_FILE "/Scriptfiles/Users/"

#define TEAM_COP 0
#define TEAM_TERRORIST 1
#define TEAM_PARAMEDIC 2
#define TEAM_MECHANIC 3
#define TEAM_ADMIN 4
#define TEAM_COP_COLOR 0x3A47DEFF //Sinine
#define TEAM_TERRORIST_COLOR 0x33AA33AA //Vihree
#define TEAM_PARAMEDIC_COLOR 0xFF0000AA //Punane
#define TEAM_MECHANIC_COLOR 0xAFAFAFAA //Harmaa
#define TEAM_ADMIN_COLOR 0xFF66FFAA
//Mitkд vдrit haluat? No cop blue Venaas kдny hakee mun scriptistд :D ok
//Vittu, venaas


#if defined FILTERSCRIPT



public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Its not a fucking filterscript :D");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Basic TDM by Majava and Max_Coldheart");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Tyhjд GameMode");
    //------------------{Spawn Pointit]--------------
    AddPlayerClass(281,2548.0806,22.8204,27.6756,84.8102,0,0,0,0,0,0);//TEAM_COP SPAWNPOINT
    AddPlayerClass(48,2606.1726,78.3045,26.8950,93.3409,0,0,0,0,0,0); // TEAM_TERRORST_SPAWNPOINT
    AddPlayerClass(50,2413.2983,89.3454,26.4722,271.6140,0,0,0,0,0,0); // TEAM_MECHANIC_SPAWN
    AddPlayerClass(275,2284.2876,72.0888,26.4844,268.2785,0,0,0,0,0,0); // TEAM_PARAMEDIC SPAWNPOINT
    AddPlayerClass(294,-2239.0886,-1722.9453,480.6817,39.2717,0,0,0,0,0,0); // Team_admin
    //Terot puuttuu viel ;D
    print("Classes sucessfully added");
    //----------------------[Autot]----------------------------------
    AddStaticVehicle(599,2553.9294,9.5614,27.2305,90.5158,0,1); // Policecar 2
    AddStaticVehicle(427,2547.5615,28.4934,26.8166,89.4700,0,1); // Policecar 3
    AddStaticVehicle(523,2545.4575,20.6441,26.2324,92.4696,0,0); // Policebike 1
    AddStaticVehicle(523,2545.5457,22.0995,26.2244,90.7955,0,0); // Policebike 2
    AddStaticVehicle(497,2563.3384,16.0512,30.4517,87.5463,0,1); // Police helicopter
    AddStaticVehicle(497,2564.1802,12.0003,31.1483,90.0110,0,1); // Policehelicopter THIS
    AddStaticVehicle(416,2263.9097,62.1417,26.6337,268.3357,1,3); // Ambulance1
    AddStaticVehicle(416,2279.9045,63.5646,26.6332,270.3857,1,3); // ambulance2
    AddStaticVehicle(457,2255.4517,74.4734,26.1112,358.2314,45,1); // hospital minicar
    AddStaticVehicle(579,2248.7920,-71.4386,26.7138,178.9435,42,42); // Libowner car
    AddStaticVehicle(462,2263.5703,-76.1887,24.1688,87.3484,1,3); // Libscooter
    AddStaticVehicle(525,2420.2927,84.8010,26.3505,87.7998,36,43); // towtruck1
    AddStaticVehicle(525,2420.3022,89.2624,26.3504,90.4678,52,54); // towtruck2
    AddStaticVehicle(552,2419.8628,93.6097,26.1730,89.3568,49,49); // towtruck3
    AddStaticVehicle(560,2231.3794,171.6325,27.1848,180.5129,33,0); // Admincar 1
    AddStaticVehicle(440,906.9126,-931.2123,42.7188,88.7180,32,32); //
    AddStaticVehicle(530,2331.2764,11.0459,26.2221,268.9272,114,1); // bar boxcar
    AddStaticVehicle(439,2288.2603,-68.9233,26.3019,180.5832,8,17); // Lib3
    AddStaticVehicle(579,2281.1111,-47.7089,26.9433,357.9398,62,62); // Lib4 Huntley
    AddStaticVehicle(579,2229.6343,-80.7082,26.3343,359.9545,10,10); // Lib5
    AddStaticVehicle(599,2553.7703,14.2490,27.2308,89.5261,0,1); // Policecar 1
    print("Vehicles spawned with no errors.");
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, -2239.0886,-1722.9453,480.6817);
    SetPlayerCameraPos(playerid, -2243.4604,-1719.4221,480.4330);
    SetPlayerCameraLookAt(playerid, -2239.0886,-1722.9453,480.6817);
    SetPlayerFacingAngle(playerid, 39.2717);
    if(classid == 0)
    {
        GameTextForPlayer(playerid, "Cops", 2500, 3);
    }
    else if(classid == 1)
    {
        GameTextForPlayer(playerid, "Terrorists", 2500, 3);
    }
    else if(classid == 2)
    {
        GameTextForPlayer(playerid, "Paramedics", 2500, 3);
    }
    else if(classid == 3)
    {
        GameTextForPlayer(playerid, "Mechanics", 2500, 3);
    }
    else if(classid == 4)
    {
        GameTextForPlayer(playerid, "Admins only!", 2500, 3);
    }
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pName[MAX_PLAYER_NAME], file[50];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), USER_FILE, pName);
    PlayerInfo[playerid][pLogged] = 0;
    if(!dini_Exists(file))
    {
        PlayerInfo[playerid][pRegistered] = 0;
        ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "Register", "Register your acount by entering your password below.", "Enter", "");
    }
    if(dini_Exists(file))
    {
        PlayerInfo[playerid][pRegistered] = 1;
        ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Login", "Enter your password and press 'login' to log in.", "Login", "");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColor(playerid);
    return 1;
}



public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandReceived(playerid, cmdtext[])
{
    return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
        return SendClientMessage(playerid, COLOR_WHITE, "   Command not found, use /cmds to see full list of commands.");
    }
    else return 1;
}
//-------------[Commands]---------
CMD:kill(playerid, params[])
{
    SetPlayerHealth(playerid, 0);
    SendClientMessage(playerid, COLOR_WHITE, "  Hint: You just committed suicide.");
    return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

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

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case REGISTER_DIALOG:
        {
            if(response)
            {
                new file[60], name[MAX_PLAYER_NAME];
                format(file, sizeof file, USER_FILE, GetPlayerName(playerid, name, sizeof(name));
                dini_Create(file);
                dini_Set(file, "Password", inputtext);
                dini_IntSet(file, "Admin Level", 0);
                dini_IntSet(file, "Score", 0);
                dini_IntSet(file, "Cookies", 0);
                dini_IntSet(file, "Kills", 0);
                dini_IntSet(file, "Deaths", 0);
            }
        }
        case LOGIN_DIALOG:
        {
            if(response)
            {
                new file[60], name[MAX_PLAYER_NAME];
                format(file, sizeof(file), USER_FILE, GetPlayerName(playerid, name, sizeof(name));
                password = dini_Get(file, "password");
                if(strcmp(password, inputtext, true))
                {
                    SendClientMessage(playerid, COLOR_BRIGHTRED, "  Invalid password, you have been kicked as a result";
                    Kick(playerid);
                }
                if(!strcmp(password, inputtext, true))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "  You are now logged in.");
                }
            }
         }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)//EIku ei viel muutes
{
    return 1;
}
SetPlayerTeamFromClass(playerid, classid)//ehkд...
{
    if(classid == 0)
    {
        gTeam[playerid] = TEAM_COP;
    }
    else if(classid == 1)
    {
        gTeam[playerid] = TEAM_TERRORIST;
    }
    else if(classid == 2)
    {
        gTeam[playerid] = TEAM_PARAMEDIC;
    }
    else
    {
        gTeam[playerid] = TEAM_MECHANIC;//
    }
}//Siellд se virhe oliki
SetPlayerToTeamColor(playerid)
{
    if(gTeam[playerid] == TEAM_COP)
    {
        SetPlayerColor(playerid, TEAM_COP_COLOR);
    }
    else if(gTeam[playerid] == TEAM_TERRORIST)
    {
        SetPlayerColor(playerid, TEAM_TERRORIST_COLOR);
    }
    else if(gTeam[playerid] == TEAM_PARAMEDIC)
    {
        SetPlayerColor(playerid, TEAM_PARAMEDIC_COLOR);
    }
    else if(gTeam[playerid] == TEAM_MECHANIC)
    {
        SetPlayerColor(playerid, TEAM_MECHANIC_COLOR);
    }
    else
    {
        SetPlayerColor(playerid, TEAM_ADMIN_COLOR);
    }
}
These are the errors:
pawn Код:
C:\Users\jussi\Documents\Gta San Andreas\samp03csvr_R2-2_win32\gamemodes\Empty.pwn(368) : error 001: expected token: ",", but found ";"
C:\Users\jussi\Documents\Gta San Andreas\samp03csvr_R2-2_win32\gamemodes\Empty.pwn(383) : error 001: expected token: ",", but found ";"
C:\Users\jussi\Documents\Gta San Andreas\samp03csvr_R2-2_win32\gamemodes\Empty.pwn(384) : error 017: undefined symbol "password"
C:\Users\jussi\Documents\Gta San Andreas\samp03csvr_R2-2_win32\gamemodes\Empty.pwn(385) : error 017: undefined symbol "password"
C:\Users\jussi\Documents\Gta San Andreas\samp03csvr_R2-2_win32\gamemodes\Empty.pwn(387) : error 001: expected token: ",", but found ";"
C:\Users\jussi\Documents\Gta San Andreas\samp03csvr_R2-2_win32\gamemodes\Empty.pwn(390) : error 017: undefined symbol "password"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


6 Errors.
Error lines:
pawn Код:
format(file, sizeof(file), USER_FILE, GetPlayerName(playerid, name, sizeof(name));
pawn Код:
format(file, sizeof(file), USER_FILE, GetPlayerName(playerid, name, sizeof(name));



Re: Register System - [HiC]TheKiller - 26.06.2011

It should be

pawn Код:
format(file, sizeof(file), USER_FILE, GetPlayerName(playerid, name, sizeof(name)));