#include // for the samp stuff #include // for the functions dini and dudb need #include // for the userdatabase, get dudb version 2.0 for this. #define dcmd(%1,%2,%3) if ((strcmp(%3, "/%1", true, %2+1) == 0)&&(((%3[%2+1]==0)&&(dcmd_%1(playerid,"")))||((%3[%2+1]==32)&&(dcmd_%1(playerid,%3[%2+2]))))) return 1 #define COLOR_SYSTEM 0xEFEFF7AA new PLAYERLIST_authed[MAX_PLAYERS]; public SystemMsg(playerid,msg[]) { if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) { SendClientMessage(playerid,COLOR_SYSTEM,msg); } return 1; } public OnPlayerCommandText(playerid,cmdtext[]) { dcmd(login,5,cmdtext); // because login has 5 characters dcmd(register,8,cmdtext); // because register has 8 characters return false; } public OnPlayerConnect(playerid) { PLAYERLIST_authed[playerid]=false; return false; } public OnPlayerDisconnect(playerid) { if (PLAYERLIST_authed[playerid]) { // Was loggedin, so save the data! dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid)); } PLAYERLIST_authed[playerid]=false; return false; } /* * This function will be useful when we need the playername * (c) by DracoBlue 2006 */ public PlayerName(playerid) { new name[255]; GetPlayerName(playerid, name, 255); return name; } /* * /register password * */ dcmd_register(playerid,params[]) { // The command shouldn't work if we already are authed if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed."); // The command shouldn't work if an account with this // nick already exists if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exists, please use '/login password'."); // Did he forgot the password? if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/register password'"); // We save the money to the accstate if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"Account successfully created. Login with '/login password' now."); return true; } /* * /login password * */ dcmd_login(playerid,params[]) { // The command shouldn't work if we already are authed if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed."); // The command shouldn't work if an account with this // nick does not exists if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exist, please use '/register password'."); // Did he forgot the password? if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/login password'"); if (udb_CheckLogin(PlayerName(playerid),params)) { // Login was correct // Following thing is the same like the missing SetPlayerCommand GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")-GetPlayerMoney(playerid)); PLAYERLIST_authed[playerid]=true; return SystemMsg(playerid,"Successfully authed!"); } else { // Login was incorrect return SystemMsg(playerid,"Login failed!"); } return true; } main() { print("\n----------------------------------"); print(" This is a blank GameModeScript"); print("----------------------------------\n"); } public OnGameModeInit() { print("GameModeInit()"); SetGameModeText("Blank Script"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; } public OnPlayerRequestClass(playerid, classid) { printf("OnPlayerRequestClass(%d, %d)", 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 OnGameModeExit() { print("GameModeExit()"); return 1; } public OnPlayerSpawn(playerid) { printf("OnPlayerSpawn(%d)", playerid); return 1; } public OnPlayerDeath(playerid, killerid, reason) { printf("OnPlayerDeath(%d, %d, %d)", playerid, killerid, reason); return 1; } public OnVehicleSpawn(vehicleid) { printf("OnVehicleSpawn(%d)", vehicleid); return 1; } public OnVehicleDeath(vehicleid, killerid) { printf("OnVehicleDeath(%d, %d)", vehicleid, killerid); return 1; } public OnPlayerText(playerid) { printf("OnPlayerText(%d)", playerid); return 1; } public OnPlayerInfoChange(playerid) { printf("OnPlayerInfoChange(%d)"); return 1; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { printf("OnPlayerEnterVehicle(%d, %d, %d)", playerid, vehicleid, ispassenger); return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { printf("OnPlayerExitVehicle(%d, %d)", playerid, vehicleid); return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { printf("OnPlayerStateChange(%d, %d, %d)", playerid, newstate, oldstate); return 1; } public OnPlayerEnterCheckpoint(playerid) { printf("OnPlayerEnterCheckpoint(%d)", playerid); return 1; } public OnPlayerLeaveCheckpoint(playerid) { printf("OnPlayerLeaveCheckpoint(%d)", playerid); return 1; } }