plugins Whirlpool sscanf
plugins Whirlpool.so sscanf.so
#include <a_samp>
#include <YSI\y_ini>
#include <YSI\y_commands>
#include <YSI\y_timers>
#include <foreach>
#include <sscanf2>
native WP_Hash(_buffer[], len, const str[]);
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define COLOR_WHITE "{FFFFFF}"
#define COLOR_RED "{F81414}"
#define COLOR_GREEN "{00FF22}"
enum USER_ENUM { Password[ 129 ], Score, Deaths, Money, Admin_Level }
new
userData[ MAX_PLAYERS ][ USER_ENUM ];
stock user_account_path(playerid)
{
new
string_path[ 128 ],
player_name[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, player_name, MAX_PLAYER_NAME );
format( string_path, sizeof ( string_path ), "%s.ini", player_name);
return
string_path;
}
format( string_path, sizeof ( string_path ), "Accounts/%s.ini", player_name);
forward @load_user_statistics(playerid, name[], value[]);
@load_user_statistics(playerid, name[], value[])
{
INI_String("Password", userData[ playerid ][ Password ], 129);
INI_Int("Money", userData[ playerid ][ Money ]);
INI_Int("AdminLevel", userData[ playerid ][ Admin_Level ]);
INI_Int("Deaths", userData[ playerid ][ Deaths ]);
INI_Int("Score", userData[ playerid ][ Score ]);
return 1;
}
public OnPlayerConnect(playerid)
{
if( fexist ( user_account_path ( playerid ) ) )
{
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome.Please log-in",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Log-in, #Quit);
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to register.", #Register, #Quit);
}
userData[ playerid ][ Admin_Level ] = 0;
userData[ playerid ][ Money ] = 0;
userData[ playerid ][ Deaths ] = 0;
userData[ playerid ][ Score ] = 0;
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_INPUT,""COLOR_WHITE"Welcome.Please log-in","You have entered an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Register, #Quit);
new
hashed_password[ 129 ];
WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );
new INI:File = INI_Open( user_account_path( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteString(File, "Password", hashed_password );
INI_WriteInt(File, "Money", 0 );
INI_WriteInt(File, "AdminLevel", 0 );
INI_WriteInt(File, "Deaths", 0 );
INI_WriteInt(File, "Score", 0 );
INI_Close(File);
SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
SpawnPlayer( playerid );
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
new
hashed_password[ 129 ];
WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );
if( !strcmp ( hashed_password, userData[ playerid ][ Password ] ) )
{
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney( playerid, userData[ playerid ][ Money ] );
SetPlayerScore( playerid, userData[ playerid ][ Score ] );
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open( user_account_path ( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteInt(File, "Money", GetPlayerMoney( playerid ) );
INI_WriteInt(File, "AdminLevel", userData[ playerid ][ Admin_Level ] );
INI_WriteInt(File, "Deaths", userData[ playerid ][ Deaths ] );
INI_WriteInt(File, "Score", GetPlayerScore( playerid ) );
INI_Close(File);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if( killerid != INVALID_PLAYER_ID ) SetPlayerScore( killerid, GetPlayerScore( killerid ) + 1 );
userData[ playerid ][ Deaths ] ++;
return 1;
}
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <YSI\y_ini>
#include <YSI\y_commands>
#include <YSI\y_timers>
#include <foreach>
#include <sscanf2>
native WP_Hash(_buffer[], len, const str[]);
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define COLOR_WHITE "{FFFFFF}"
#define COLOR_RED "{F81414}"
#define COLOR_GREEN "{00FF22}"
enum USER_ENUM { Password[ 129 ], Score, Deaths, Money, Admin_Level }
new
userData[ MAX_PLAYERS ][ USER_ENUM ];
stock user_account_path(playerid)
{
new
string_path[ 128 ],
player_name[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, player_name, MAX_PLAYER_NAME );
format( string_path, sizeof ( string_path ), "%s.ini", player_name);
return
string_path;
}
forward @load_user_statistics(playerid, name[], value[]);
@load_user_statistics(playerid, name[], value[])
{
INI_String("Password", userData[ playerid ][ Password ], 129);
INI_Int("Money", userData[ playerid ][ Money ]);
INI_Int("AdminLevel", userData[ playerid ][ Admin_Level ]);
INI_Int("Deaths", userData[ playerid ][ Deaths ]);
INI_Int("Score", userData[ playerid ][ Score ]);
return 1;
}
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
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 OnPlayerConnect(playerid)
{
if( fexist ( user_account_path ( playerid ) ) )
{
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome.Please log-in",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Log-in, #Quit);
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to register.", #Register, #Quit);
}
userData[ playerid ][ Admin_Level ] = 0;
userData[ playerid ][ Money ] = 0;
userData[ playerid ][ Deaths ] = 0;
userData[ playerid ][ Score ] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open( user_account_path ( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteInt(File, "Money", GetPlayerMoney( playerid ) );
INI_WriteInt(File, "AdminLevel", userData[ playerid ][ Admin_Level ] );
INI_WriteInt(File, "Deaths", userData[ playerid ][ Deaths ] );
INI_WriteInt(File, "Score", GetPlayerScore( playerid ) );
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if( killerid != INVALID_PLAYER_ID ) SetPlayerScore( killerid, GetPlayerScore( killerid ) + 1 );
userData[ playerid ][ Deaths ] ++;
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[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick( playerid );
if ( response )
{
if( !strlen ( inputtext ) ) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Welcome.Please log-in","You have enteCOLOR_RED an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Register, #Quit);
new
hashed_password[ 129 ];
WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );
new INI:File = INI_Open( user_account_path( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteString(File, "Password", hashed_password );
INI_WriteInt(File, "Money", 0 );
INI_WriteInt(File, "AdminLevel", 0 );
INI_WriteInt(File, "Deaths", 0 );
INI_WriteInt(File, "Score", 0 );
INI_Close(File);
SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
SpawnPlayer( playerid );
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
new
hashed_password[ 129 ];
WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );
if( !strcmp ( hashed_password, userData[ playerid ][ Password ] ) )
{
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney( playerid, userData[ playerid ][ Money ] );
SetPlayerScore( playerid, userData[ playerid ][ Score ] );
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
[statistics] Password = 3F4811B9E6C37CE5900ADA5BC660C8632D13EA28A11DD0C54E3E0FD4C776F285AB1678C7FA708FF0078FB495BC05C09D654B063F07EB1859F3440E4B5F1B5449 Money = 0 AdminLevel = 0 Score = 0 Deaths = 0
YCMD:help( playerid, params[], help )
{
if ( help ) return SendClientMessage( playerid, -1, #Displays help about a command );
/* if help parameter occured (e.g player types "/help help") it will return the message above */
if ( isnull ( params ) ) return SendClientMessage( playerid, -1, #Syntax: /help [command] );
/* if parameters are null (e.g player types "/help") it will return the message above */
Command_ReProcess(playerid, params, true);
/* Call to put text through the command processor, with the help functions enabled or disabled */
return 1;
}
YCMD:teleport( playerid, params[], help )
{
if ( help ) return SendClientMessage( playerid, -1, #This command teleports you somewhere! );
// Do your code
return 1;
}
YCMD:commands(playerid, params[], help)
{
if ( help ) return SendClientMessage(playerid, -1, #Lists all the commands a player can use! );
new
count = Command_GetPlayerCommandCount( playerid );
for ( new i = 0; i != count; ++i) SendClientMessage( playerid, -1, Command_GetNext ( i, playerid ) );
return 1;
}
/* custom message */
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if( !success )
{
format( cmdtext, 128, "ERROR: Command %s does not exist, type /commands for all available commands", cmdtext );
SendClientMessage( playerid, -1, cmdtext );
}
return 1;
}
/* regular Unknown message */
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if( !success ) return false;
return true;
}
public OnFilterScriptInit()
{
Command_AddAltNamed("teleport", "tp");
return 1;
}
YCMD:setadmin( playerid, params[], help )
{
new
TargetID, AdminLevel, PlayerName[ MAX_PLAYER_NAME ], TargetName[ MAX_PLAYER_NAME ], _message[ 128 ];
if ( help ) return SendClientMessage( playerid, -1, #This command promotes someone to admin );
if ( sscanf ( params, "ri", TargetID, AdminLevel ) ) return SendClientMessage( TargetID, -1, #Syntax /setadmin <playername/id> <level> );
if ( TargetID == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, #Player offline );
GetPlayerName( playerid, PlayerName, sizeof ( PlayerName ) );
GetPlayerName( TargetID, TargetName, sizeof ( TargetName ) );
format( _message, sizeof ( _message ), "You have been promoted to admin level %d by %s", AdminLevel, PlayerName );
SendClientMessage( TargetID, -1, _message );
format( _message, sizeof ( _message ), "You have promoted %s to admin level %d", TargetName, AdminLevel );
SendClientMessage( playerid, -1, _message );
userData[ TargetID ][ Admin_Level ] = AdminLevel;
return 1;
}
Код:
Format Use L(true/false) Optional logical truthity l Logical truthity B(binary) Optional binary number b Binary number N(any format number) Optional number n Number C(character) Optional character c Character I(integer) Optional integer i Integer D(integer) Optional integer d Integer H(hex value) Optional hex number h Hex number O(octal value) Optional octal value o Octal value F(float) Optional floating point number f Floating point number G(float/INFINITY/-INFINITY/NAN/NAN_E) Optional float with IEEE definitions g Float with IEEE definitions { Open quiet section } Close quiet section P<delimiter> Invalid delimiter change p<delimiter> Delimiter change Z(string)[length] Invalid optional string z(string)[length] Deprecated optional string S(string)[length] Optional string s[length] String U(name/id) Optional user (bot/player) u User (bot/player) Q(name/id) Optional bot (bot) q Bot (bot) R(name/id) Optional player (player) r Player (player) A<type>(default)[length] Optional array of given type a<type>[length] Array of given type E<specification>(default) Optional enumeration of given layout e<specification> Enumeration of given layout 'string' Search string % Deprecated optional specifier prefix |
if ( !sscanf ( params, "specifiers_here", variables_here ) ) /* if player enteres CORRECT usage of the command NOTE THE "!" */
{
// Do your code
}
if ( sscanf ( params, "specifiers_here", variables_here ) ) /* if player enteres INCORRECT usage of the command */
{
// Do your code
}
public OnFilterScriptInit()
{
Command_AddAltNamed("teleport", "tp");
repeat UpdatePermissions();
return 1;
}
timer UpdatePermissions[1000]()
{
foreach( Player, i )
{
if ( IsPlayerAdmin ( i ) )
{
Command_SetPlayerNamed("setadmin", i, true );
}
else
{
Command_SetPlayerNamed("setadmin", i, false );
}
}
}
YCMD:stats( playerid, params[], help )
{
if ( help ) return SendClientMessage( playerid, -1, #This command displays your current statistics );
if ( isnull ( params ) )
{
new
sString[ 128 ],
a_level = userData[ playerid ][ Admin_Level ],
money = userData[ playerid ][ Money ],
score = userData[ playerid ][ Score ],
deaths = userData[ playerid ][ Deaths ];
format ( sString, sizeof ( sString ), "Your stats are: Admin Level: %d | Money: %d | Score: %d | Deaths: %d", a_level, money, score, deaths );
SendClientMessage( playerid, -1, sString );
}
return 1;
}
stock GetPlayerAdminLevel(playerid)
{
new
a_level_string[ 128 ];
if ( userData[ playerid ][ Admin_Level ] == 1 )
format( a_level_string, sizeof ( a_level_string ), "Little Admin" );
else if ( userData[ playerid ][ Admin_Level ] == 2 )
format( a_level_string, sizeof ( a_level_string ), "Medium Admin" );
else if ( userData[ playerid ][ Admin_Level ] == 3 )
format( a_level_string, sizeof ( a_level_string ), "Head Admin" );
else
format( a_level_string, sizeof ( a_level_string ), "Unknown admin level!" );
return a_level_string;
}
YCMD:myadminlevel(playerid, params[], help)
{
if ( help ) return SendClientMessage( playerid, -1, #This command displays your current admin level );
if ( isnull ( params ) )
{
new
sString[ 128 ];
format( sString, sizeof ( sString ), "Your current admin level is: %s", GetPlayerAdminLevel(playerid) );
SendClientMessage( playerid, -1, sString );
}
return 1;
}
timer UpdatePermissions[1000]()
{
foreach( Player, i )
{
if ( IsPlayerAdmin ( i ) )
{
Command_SetPlayerNamed("setadmin", i, true );
Command_SetPlayerNamed("stats", i, false );
}
if ( userData[ i ][ Admin_Level ] == 2 )
{
Command_SetPlayerNamed("stats", i, true );
Command_SetPlayerNamed("setadmin", i, false );
}
else
{
Command_SetPlayerNamed("setadmin", i, false );
Command_SetPlayerNamed("stats", i, false );
}
}
}
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <YSI\y_ini>
#include <YSI\y_commands>
#include <YSI\y_timers>
#include <foreach>
#include <sscanf2>
native WP_Hash(_buffer[], len, const str[]);
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define COLOR_WHITE "{FFFFFF}"
#define COLOR_RED "{F81414}"
#define COLOR_GREEN "{00FF22}"
enum USER_ENUM { Password[ 129 ], Score, Deaths, Money, Admin_Level }
new
userData[ MAX_PLAYERS ][ USER_ENUM ];
stock user_account_path(playerid)
{
new
string_path[ 128 ],
player_name[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, player_name, MAX_PLAYER_NAME );
format( string_path, sizeof ( string_path ), "%s.ini", player_name);
return
string_path;
}
forward @load_user_statistics(playerid, name[], value[]);
@load_user_statistics(playerid, name[], value[])
{
INI_String("Password", userData[ playerid ][ Password ], 129);
INI_Int("Money", userData[ playerid ][ Money ]);
INI_Int("AdminLevel", userData[ playerid ][ Admin_Level ]);
INI_Int("Deaths", userData[ playerid ][ Deaths ]);
INI_Int("Score", userData[ playerid ][ Score ]);
return 1;
}
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
Command_AddAltNamed("teleport", "tp");
repeat UpdatePermissions();
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
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 OnPlayerConnect(playerid)
{
if( fexist ( user_account_path ( playerid ) ) )
{
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome.Please log-in",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Log-in, #Quit);
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to register.", #Register, #Quit);
}
userData[ playerid ][ Admin_Level ] = 0;
userData[ playerid ][ Money ] = 0;
userData[ playerid ][ Deaths ] = 0;
userData[ playerid ][ Score ] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open( user_account_path ( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteInt(File, "Money", GetPlayerMoney( playerid ) );
INI_WriteInt(File, "AdminLevel", userData[ playerid ][ Admin_Level ] );
INI_WriteInt(File, "Deaths", userData[ playerid ][ Deaths ] );
INI_WriteInt(File, "Score", GetPlayerScore( playerid ) );
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if( killerid != INVALID_PLAYER_ID ) SetPlayerScore( killerid, GetPlayerScore( killerid ) + 1 );
userData[ playerid ][ Deaths ] ++;
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[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick( playerid );
if ( response )
{
if( !strlen ( inputtext ) ) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Welcome.Please log-in","You have enteCOLOR_RED an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Register, #Quit);
new
hashed_password[ 129 ];
WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );
new INI:File = INI_Open( user_account_path( playerid ) );
INI_SetTag(File, "statistics" );
INI_WriteString(File, "Password", hashed_password );
INI_WriteInt(File, "Money", 0 );
INI_WriteInt(File, "AdminLevel", 0 );
INI_WriteInt(File, "Deaths", 0 );
INI_WriteInt(File, "Score", 0 );
INI_Close(File);
SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
SpawnPlayer( playerid );
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
new
hashed_password[ 129 ];
WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );
if( !strcmp ( hashed_password, userData[ playerid ][ Password ] ) )
{
INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney( playerid, userData[ playerid ][ Money ] );
SetPlayerScore( playerid, userData[ playerid ][ Score ] );
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
/* OPTIONAL
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if( !success )
{
format( cmdtext, 128, "ERROR: Command %s does not exist, type /commands for all available commands", cmdtext );
SendClientMessage( playerid, -1, cmdtext );
}
return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if( !success ) return false;
return true;
}
*/
/* timers */
timer UpdatePermissions[1000]()
{
foreach( Player, i )
{
if ( IsPlayerAdmin ( i ) )
{
Command_SetPlayerNamed("setadmin", i, true );
Command_SetPlayerNamed("stats", i, false );
}
if ( userData[ i ][ Admin_Level ] == 2 )
{
Command_SetPlayerNamed("stats", i, true );
Command_SetPlayerNamed("setadmin", i, false );
}
else
{
Command_SetPlayerNamed("setadmin", i, false );
Command_SetPlayerNamed("stats", i, false );
}
}
}
/* stocks */
stock GetPlayerAdminLevel(playerid)
{
new
a_level_string[ 128 ];
if ( userData[ playerid ][ Admin_Level ] == 1 )
format( a_level_string, sizeof ( a_level_string ), "Little Admin" );
else if ( userData[ playerid ][ Admin_Level ] == 2 )
format( a_level_string, sizeof ( a_level_string ), "Medium Admin" );
else if ( userData[ playerid ][ Admin_Level ] == 3 )
format( a_level_string, sizeof ( a_level_string ), "Head Admin" );
else
format( a_level_string, sizeof ( a_level_string ), "Unknown admin level!" );
return a_level_string;
}
/* commands */
YCMD:help( playerid, params[], help )
{
if ( help ) return SendClientMessage( playerid, -1, #Displays help about a command );
if ( isnull ( params ) ) return SendClientMessage( playerid, -1, #Syntax: /help [command] );
Command_ReProcess(playerid, params, true);
return 1;
}
YCMD:teleport( playerid, params[], help )
{
if ( help ) return SendClientMessage( playerid, -1, #This command teleports you somewhere! );
return 1;
}
YCMD:commands(playerid, params[], help)
{
if ( help ) return SendClientMessage(playerid, -1, #Lists all the commands a player can use! );
new
count = Command_GetPlayerCommandCount( playerid );
for ( new i = 0; i != count; ++i) SendClientMessage( playerid, -1, Command_GetNext ( i, playerid ) );
return 1;
}
YCMD:setadmin( playerid, params[], help )
{
new
TargetID, AdminLevel, PlayerName[ MAX_PLAYER_NAME ], TargetName[ MAX_PLAYER_NAME ], _message[ 128 ];
if ( help ) return SendClientMessage( playerid, -1, #This command promotes someone to admin );
if ( sscanf ( params, "ri", TargetID, AdminLevel ) ) return SendClientMessage( TargetID, -1, #Syntax /setadmin <playername/id> <level> );
if ( TargetID == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, #Player offline );
GetPlayerName( playerid, PlayerName, sizeof ( PlayerName ) );
GetPlayerName( TargetID, TargetName, sizeof ( TargetName ) );
format( _message, sizeof ( _message ), "You have been promoted to admin level %d by %s", AdminLevel, PlayerName );
SendClientMessage( TargetID, -1, _message );
format( _message, sizeof ( _message ), "You have promoted %s to admin level %d", TargetName, AdminLevel );
SendClientMessage( playerid, -1, _message );
userData[ TargetID ][ Admin_Level ] = AdminLevel;
return 1;
}
YCMD:stats( playerid, params[], help )
{
if ( help ) return SendClientMessage( playerid, -1, #This command displays your current statistics );
if ( isnull ( params ) )
{
new
sString[ 128 ],
a_level = userData[ playerid ][ Admin_Level ],
money = userData[ playerid ][ Money ],
score = userData[ playerid ][ Score ],
deaths = userData[ playerid ][ Deaths ];
format ( sString, sizeof ( sString ), "Your stats are: Admin Level: %d | Money: %d | Score: %d | Deaths: %d", a_level, money, score, deaths );
SendClientMessage( playerid, -1, sString );
}
return 1;
}
YCMD:myadminlevel(playerid, params[], help)
{
if ( help ) return SendClientMessage( playerid, -1, #This command displays your current admin level );
if ( isnull ( params ) )
{
new
sString[ 128 ];
format( sString, sizeof ( sString ), "Your current admin level is: %s", GetPlayerAdminLevel(playerid) );
SendClientMessage( playerid, -1, sString );
}
return 1;
}
error 017: undefined symbol "repeat"
error 017: undefined symbol "UpdatePermissions"
//Line 55
repeat UpdatePermissions();
error 010: invalid function or declaration
//Line 153
timer UpdatePermissions[1000]()
//Line 155
foreach( Player, i )
//Line 157
if ( IsPlayerAdmin ( i ) )
error 021: symbol already defined: "Command_SetPlayerNamed"
//Line 159
Command_SetPlayerNamed("setadmin", i, true );
//Line 163
Command_SetPlayerNamed("setlevel", i, false );
error 010: invalid function or declaration
//Line 161
else
"You have enter an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"
"You have enteCOLOR_RED an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"
Awesome Tutorial SmiT
Really Nice Job! Edit: I tested it, but I got some errors. How to fix them ..code |
code...
thats wrong or? it says wrong password but its about to register |
fatal error 111: user error: "Old foreach.inc files are no longer compatible with YSI."
warning 235: public function lacks forward declaration (symbol "OnPlayerTakeDamage")
warning 235: public function lacks forward declaration (symbol "OnPlayerGiveDamage")
Those are 0.3d callbacks, just ignore them if you're not on that.
|
stock GetPlayerAdminLevel(playerid)
{
new
a_level_string[128];
if (userData[playerid][Admin_Level] == 1)
format(a_level_string, sizeof(a_level_string), "Help Operator");
if (userData[playerid][Admin_Level] == 2 )
format(a_level_string, sizeof(a_level_string), "Moderator");
if (userData[playerid][Admin_Level] == 3 )
format(a_level_string, sizeof(a_level_string), "Global Moderator");
if (userData[playerid][Admin_Level] == 4 )
format(a_level_string, sizeof(a_level_string), "Management");
if (userData[playerid][Admin_Level] == 5 )
format(a_level_string, sizeof(a_level_string), "Head Admin");
else
format(a_level_string, sizeof(a_level_string), "Unknown admin level!");
return a_level_string;
}