I just tested the register/login system from SII! But it doesn't work! When I run my server, the log says!
Loaded log file: "server_log.txt".
[00:57:19] Loaded 0 plugins.
[00:57:19] Loading filter script 'base.amx'...
--Base FS loaded.
[00:57:19] Loading filter script 'gl_actions.amx'...
[00:57:19] Loading filter script 'gl_property.amx'...
[00:57:19] Loading filter script 'gl_realtime.amx'...
[00:57:19] Loading filter script 'gl_mapicon.amx'...
[00:57:19] Loading filter script 'ls_elevator.amx'...
[00:57:19] Loaded 6 filter scripts.
[00:57:19] Script[gamemodes/deathmatch.amx]: Run time error 20: "Invalid index parameter (bad entry point)"
Ok, my script is not SO big, I'm showing u everything now! (No worry, I marked the lines I added!)
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <SII> //added new
#define DIALOG_REGISTER 2000//added new
#define DIALOG_LOGIN 2001//added new
#define WHITE "{FFFFFF}"//added new
#define RED "{F81414}"//added new
#define GREEN "{00FF22}"//added new
#define LIGHTBLUE "{00CED1}"//added new
new gPlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];//added new
#define TEAM_GROVE 1
#define TEAM_BALLA 2
#define TEAM_VAGOS 3
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple
#define TEAM_VAGOS_COLOR 0xFFFF00AA // Yellow
new gTeam[MAX_PLAYERS];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
enum pInfo //added new
{
pPass,
pScore,
pCash,
pAdmin,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
stock getINI(playerid) //added new
{
new account[64];
format(account,30,"Users/%s.ini",gPlayerName[playerid]);
return account;
}
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("***Live your own life as a GangstA***");
AddPlayerClass(102, 1974.4895,-1157.0608,20.9505,95.6222, 30, 1000, 29, 1000, 27, 1000); //Ballas1
AddPlayerClass(103, 1976.7120,-1183.5504,26.0188,98.0542, 22, 1000, 34, 1000, 29, 1000); //Ballas2
AddPlayerClass(104, 2092.0271,-1166.3419,26.5859,89.4869, 28, 1000, 23, 1000, 4, 1000); //Ballas3
AddPlayerClass(269, 2486.7598,-1647.5186,14.0703,187.5500, 30, 1000, 25, 1000, 24, 1000); //Smoke
AddPlayerClass(271, 2459.9001,-1688.4135,13.5280,2.9949, 33, 1000, 32, 1000, 31, 1000); //Ryder
AddPlayerClass(270,2516.3430,-1674.3085,13.9348,81.6422,32,1000,31,1000,34,1000); // Sweet
AddPlayerClass(0,2495.4890,-1688.2717,13.7022,5.9233,1,0,29,1000,27,1000); // CJ
AddPlayerClass(105,2451.6484,-1642.4531,13.7357,182.6713,28,1000,33,1000,22,1000); // grove1
AddPlayerClass(106,2413.7170,-1647.2096,14.0119,174.8622,26,1000,30,1000,23,1000); // grove2
AddPlayerClass(107,2408.6982,-1674.0126,13.6037,356.5973,34,1000,30,1000,32,1000); // grove3
AddPlayerClass(108,2571.8352,-1091.2091,66.9639,48.7203,29,1000,9,0,31,1000); // Vagos1
AddPlayerClass(109,2569.7373,-1088.5804,67.0079,220.8869,22,1000,33,1000,30,1000); // Vagos2
AddPlayerClass(110,2576.0371,-1070.5568,69.8322,89.5007,27,1000,24,1000,32,1000); // Vagos3
return 1;
}
public OnGameModeExit()
{
return 1;
}
SetPlayerTeamFromClass(playerid, classid)
{
if (classid == 0)
{
gTeam[playerid] = TEAM_BALLA;
}
else if(classid == 1)
{
gTeam[playerid] = TEAM_GROVE;
}
else if(classid == 2)
{
gTeam[playerid] = TEAM_VAGOS;
}
}
SetPlayerToTeamColor(playerid)
{
if (gTeam[playerid] == TEAM_GROVE)
{
SetPlayerColor(playerid, TEAM_GROVE_COLOR);
}
else if (gTeam[playerid] == TEAM_BALLA)
{
SetPlayerColor(playerid, TEAM_BALLA_COLOR);
}
else if (gTeam[playerid] == TEAM_VAGOS)
{
SetPlayerColor(playerid, TEAM_VAGOS_COLOR);
}
}
public OnPlayerRequestClass(playerid, classid)
{
switch ( classid )
{
case 0:
{
SetPlayerTeamFromClass(playerid, classid);
SetPlayerPos(playerid, 1992.1263,-1175.7640,20.1479);//Ballas1
SetPlayerFacingAngle( playerid, 187.0574 );
SetPlayerCameraPos(playerid, 1991.3074,-1179.9628,20.0234);
SetPlayerCameraLookAt(playerid, 1992.1263,-1175.7640,20.1479);
}
case 1:
{
SetPlayerTeamFromClass(playerid, classid);
SetPlayerPos(playerid, 1992.1263,-1175.7640,20.1479);//Ballas2
SetPlayerFacingAngle( playerid, 187.0574 );
SetPlayerCameraPos(playerid, 1991.3074,-1179.9628,20.0234);
SetPlayerCameraLookAt(playerid, 1992.1263,-1175.7640,20.1479);
}
case 2:
{
SetPlayerTeamFromClass(playerid, classid);
SetPlayerPos(playerid, 1992.1263,-1175.7640,20.1479);//Ballas3
SetPlayerFacingAngle( playerid, 187.0574 );
SetPlayerCameraPos(playerid, 1991.3074,-1179.9628,20.0234);
SetPlayerCameraLookAt(playerid, 1992.1263,-1175.7640,20.1479);
}
case 3:
{
SetPlayerPos(playerid, 2486.7598,-1647.5186,14.0703);//Smoke
SetPlayerFacingAngle( playerid, 187.5500 );
SetPlayerCameraPos(playerid, 2486.4346,-1646.0953-5,14.0703);
SetPlayerCameraLookAt(playerid, 2486.7598,-1647.5186,14.0703);
}
case 4:
{
SetPlayerPos(playerid, 2459.4480, -1690.9413, 13.5454);//Ryder
SetPlayerFacingAngle( playerid, 0.0000 );
SetPlayerCameraPos(playerid, 2459.6384, -1687.1152, 13.5413);
SetPlayerCameraLookAt(playerid, 2459.4480, -1690.9413, 13.5454);
}
case 5:
{
SetPlayerPos(playerid, 2522.6121, -1679.1656, 15.4970);//sweet
SetPlayerFacingAngle( playerid, 88.0000 );
SetPlayerCameraPos(playerid, 2518.7092, -1677.2450, 14.4855);
SetPlayerCameraLookAt(playerid, 2522.6121, -1679.1656, 15.4970);
}
case 6:
{
SetPlayerPos(playerid, 2491.8879, -1692.5519, 14.7656);//CJ
SetPlayerFacingAngle(playerid, 0.0000 );
SetPlayerCameraPos(playerid, 2491.4521, -1686.6085, 14.9499);
SetPlayerCameraLookAt(playerid, 2491.8879, -1692.5519, 14.7656);
}
case 7:
{
SetPlayerPos(playerid, 2451.6484,-1642.4531,13.7357);//grove1
SetPlayerFacingAngle(playerid, 182.6713 );
SetPlayerCameraPos(playerid, 2451.9380,-1644.4344,13.4585);
SetPlayerCameraLookAt(playerid, 2451.6484,-1642.4531,13.7357);
}
case 8:
{
SetPlayerPos(playerid, 2413.7170,-1647.2096,14.0119);//grove2
SetPlayerFacingAngle(playerid, 174.8622 );
SetPlayerCameraPos(playerid, 2414.0659,-1649.3937,13.5427);
SetPlayerCameraLookAt(playerid, 2413.7170,-1647.2096,14.0119);
}
case 9:
{
SetPlayerPos(playerid, 2408.6982,-1674.0126,13.6037);//grove3
SetPlayerFacingAngle(playerid, 356.5973 );
SetPlayerCameraPos(playerid, 2409.2739,-1671.2870,13.5758);
SetPlayerCameraLookAt(playerid, 2408.6982,-1674.0126,13.6037);
}
case 10:
{
SetPlayerPos(playerid, 2571.8352,-1091.2091,66.9639);//Vagos1
SetPlayerFacingAngle(playerid, 48.7203 );
SetPlayerCameraPos(playerid, 2570.1152,-1089.5372,66.8601);
SetPlayerCameraLookAt(playerid, 2571.8352,-1091.2091,66.9639);
}
case 11:
{
SetPlayerPos(playerid, 2519.7849,-1112.9146,56.3307);//Vagos2
SetPlayerFacingAngle(playerid, 281.2392 );
SetPlayerCameraPos(playerid, 2521.8833,-1112.5847,56.2635);
SetPlayerCameraLookAt(playerid, 2519.7849,-1112.9146,56.3307);
}
case 12:
{
SetPlayerPos(playerid, 2576.0371,-1070.5568,69.8322);//Vagos3
SetPlayerFacingAngle(playerid, 89.5007 );
SetPlayerCameraPos(playerid, 2574.1665,-1070.4742,69.2872);
SetPlayerCameraLookAt(playerid, 2576.0371,-1070.5568,69.8322);
}
}
return 1;
}
public OnPlayerConnect(playerid) //added new
{
GetPlayerName(playerid, gPlayerName[playerid], MAX_PLAYER_NAME);
if (fexist(getINI(playerid)))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""WHITE"Registering...",""WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason) //added new
{
if(INI_Open(getINI(playerid))) {
INI_WriteInt("Score",PlayerInfo[playerid][pScore]);
INI_WriteInt("Cash",PlayerInfo[playerid][pCash]);
INI_WriteInt("Admin",PlayerInfo[playerid][pAdmin]);
INI_Save();
INI_Close();
}
}
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 OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
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[]) //ADDED NEW
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if (response)
{
if(!strlen(inputtext)) {
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
}
if(INI_Open(getINI(playerid))) {
INI_WriteString("Password",inputtext);
INI_WriteInt("Score",1);
INI_WriteInt("Cash",5000);
INI_WriteInt("Admin",0);
INI_Save();
INI_Close();
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
}
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(!strlen(inputtext)) {
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
}
if(INI_Open(getINI(playerid))) {
INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);
if(strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
}
SetPlayerScore( playerid, INI_ReadInt("Score" ) );
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
INI_Close();
}
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
When I connect to my server, he says I have to register and give my passowrd!OK!
Then I connect again to my server, but he says again that I have to register!OMG! I had to log myselfe in!
Why are you using OnFilterScriptInit and OnFilterScriptExit callbacks if you'll never use them? Also, consider adding
to your script, outside of all other functions. This will remove this error from your client:
Also, please show the getINI funciton. And if you copied this from a tutorial, you should probably post in it's topic.
Hmm, is the getINI function not in my code above? If not, from where could I get it's code?
Ah, sorry, I didn't even think to look there (duh).
Anyway, is the file actually created in the scriptfiles/Users file? If not, you should add fcreate() function inside OnDialogResponse where the player registers to create the file.
Your using my register system and it works fine. Either re-do it using the instructions given, or download the .pwn file i've placed in my tutorial.
No, it works NOT fine! So why when I connect to my server, he wants just registration!?? If he would know me, he had to say: