Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dutils>
- #include <dudb>
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- //Colors//
- #define COLOR_SYSTEM 0xEFEFF7AA
- #define green 0x33FF33AA
- #define blue 0x00FFFFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- enum PlayerStat
- {
- Kills,
- Deaths
- };
- new PlayerStats[MAX_PLAYERS][PlayerStat];
- new joined[MAX_PLAYERS];
- new put[MAX_PLAYERS] = 0;
- new weap[MAX_PLAYERS] = 0;
- new gived[MAX_PLAYERS] = 0;
- #pragma tabsize 0
- #pragma unused strtok
- #if defined FILTERSCRIPT
- #endif
- public OnPlayerRequestSpawn(playerid)
- {
- if (udb_Exists(PlayerName(playerid)))
- {
- if (!joined[playerid]){
- return 0;
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- if (joined[playerid]) //If the player logged in
- {
- SavePlayerPosition(playerid); //Position Saving
- SavePlayerWeapon(playerid); //Weapon Saving
- dUserSetINT(PlayerName(playerid)).("score",GetPlayerScore(playerid)); //Save Score
- dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid)); //Save Money
- dUserSetINT(PlayerName(playerid)).("kills",PlayerStats[playerid][Kills]); //Save Kills
- dUserSetINT(PlayerName(playerid)).("deaths",PlayerStats[playerid][Deaths]); //Save Deaths
- new Float:health;
- GetPlayerHealth(playerid, Float:health);
- new Float:armour;
- GetPlayerArmour(playerid, Float:armour);
- dUserSetINT(PlayerName(playerid)).("health",floatround(health)); //Save Health
- dUserSetINT(PlayerName(playerid)).("armour",floatround(armour)); //Save Armour
- dUserSetINT(PlayerName(playerid)).("skin",GetPlayerSkin(playerid)); //Save Skin
- dUserSetINT(PlayerName(playerid)).("color",GetPlayerColor(playerid)); //Save Color
- dUserSetINT(PlayerName(playerid)).("wanted",GetPlayerWantedLevel(playerid)); //Save WantedLevel
- dUserSetINT(PlayerName(playerid)).("virtual",GetPlayerVirtualWorld(playerid)); //Save VirtualWorld
- joined[playerid]=0;
- put[playerid]=0;
- weap[playerid]=0;
- gived[playerid]=0;
- }
- return false;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerStats[playerid][Deaths] = 0;
- PlayerStats[playerid][Kills] = 0;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if (joined[playerid]) //If the player logged in
- {
- PlayerStats[playerid][Deaths]++;
- dUserSetINT(PlayerName(playerid)).("skin",GetPlayerSkin(playerid)); //Save Skin
- dUserSetINT(PlayerName(playerid)).("color",GetPlayerColor(playerid)); //Save Color
- dUserSetINT(PlayerName(playerid)).("wanted",GetPlayerWantedLevel(playerid)); //Save WantedLevel
- dUserSetINT(PlayerName(playerid)).("virtual",GetPlayerVirtualWorld(playerid)); //Save VirtualWorld
- SavePlayerPosition(playerid);
- }
- if (joined[killerid]) //If the killer logged in
- {
- PlayerStats[killerid][Kills]++;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(login,5,cmdtext);
- dcmd(register,8,cmdtext);
- return 0;
- }
- public OnPlayerSpawn(playerid)
- {
- if (joined[playerid] && gived[playerid] == 0) //If the player logged in
- {
- GiveSavedWeapon(playerid);
- PutPlayerPosition(playerid);
- SetPlayerHealth(playerid, float(dUserINT(PlayerName(playerid)).("health"))); //Load Health
- SetPlayerArmour(playerid, float(dUserINT(PlayerName(playerid)).("armour"))); // Load Armour
- SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin")); //Load Skin
- SetPlayerColor(playerid,dUserINT(PlayerName(playerid)).("color")); //Load Color
- SetPlayerWantedLevel(playerid,dUserINT(PlayerName(playerid)).("wanted")); //Load WantedLevel
- SetPlayerVirtualWorld(playerid,dUserINT(PlayerName(playerid)).("virtual")); //Load VirtualWorld
- gived[playerid]=1;
- }
- if (joined[playerid] && gived[playerid] == 1) //If the player logged in
- {
- PutPlayerPosition(playerid);
- SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin")); //Load Skin
- SetPlayerColor(playerid,dUserINT(PlayerName(playerid)).("color")); //Load Color
- SetPlayerWantedLevel(playerid,dUserINT(PlayerName(playerid)).("wanted")); //Load WantedLevel
- SetPlayerVirtualWorld(playerid,dUserINT(PlayerName(playerid)).("virtual")); //Load VirtualWorld
- }
- return 1;
- }
- stock SystemMsg(playerid,msg[]) {
- if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
- SendClientMessage(playerid,COLOR_SYSTEM,msg);
- }
- return 1;
- }
- stock PlayerName(playerid)
- {
- new name[128];
- GetPlayerName(playerid, name, 128);
- return name;
- }
- dcmd_register(playerid,params[])
- {
- if (joined[playerid]) return SystemMsg(playerid,"");
- if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"");
- if (strlen(params)==0) return SystemMsg(playerid,"");
- if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"");
- return true;
- }
- dcmd_login(playerid,params[])
- {
- if (joined[playerid]) return SystemMsg(playerid,"");
- if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"");
- if (strlen(params)==0) return SystemMsg(playerid,"");
- if (udb_CheckLogin(PlayerName(playerid),params))
- {
- SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("score")); //Load Score
- GivePlayerMoney(playerid, dUserINT(PlayerName(playerid)).("money")); //Load Money
- PlayerStats[playerid][Deaths] = (dUserINT(PlayerName(playerid)).("deaths")); //Load Deaths
- PlayerStats[playerid][Kills] = (dUserINT(PlayerName(playerid)).("kills")); // Load Kills
- joined[playerid]=1;
- return SystemMsg(playerid,"");
- }
- // login was incorrect
- return SystemMsg(playerid,"");
- }
- SavePlayerPosition(playerid)
- {
- new Float:x,Float:y,Float:z, interior;
- GetPlayerPos(playerid,x,y,z);
- interior = GetPlayerInterior(playerid);
- dUserSetINT(PlayerName(playerid)).("x1",floatround(x)); //Player's X
- dUserSetINT(PlayerName(playerid)).("y1",floatround(y)); //Player's Y
- dUserSetINT(PlayerName(playerid)).("z1",floatround(z)); //Player's Z
- dUserSetINT(PlayerName(playerid)).("interior1",interior); //Player's Interior
- }
- PutPlayerPosition(playerid)
- {
- if (dUserINT(PlayerName(playerid)).("x1")!=0)
- {
- if(put[playerid]==0)
- {
- SetPlayerPos(playerid, float(dUserINT(PlayerName(playerid)).("x1")), float(dUserINT(PlayerName(playerid)).("y1")), float(dUserINT(PlayerName(playerid)).("z1")) );
- SetPlayerInterior(playerid, (dUserINT(PlayerName(playerid)).("interior1")) );
- put[playerid]=1;
- }
- }
- }
- SavePlayerWeapon(playerid)
- {
- new weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6;
- GetPlayerWeaponData(playerid,2,weap1,ammo1);
- GetPlayerWeaponData(playerid,3,weap2,ammo2);
- GetPlayerWeaponData(playerid,4,weap3,ammo3);
- GetPlayerWeaponData(playerid,5,weap4,ammo4);
- GetPlayerWeaponData(playerid,6,weap5,ammo5);
- GetPlayerWeaponData(playerid,7,weap6,ammo6);
- dUserSetINT(PlayerName(playerid)).("weap1",weap1); dUserSetINT(PlayerName(playerid)).("weap1ammo",ammo1);
- dUserSetINT(PlayerName(playerid)).("weap2",weap2); dUserSetINT(PlayerName(playerid)).("weap2ammo",ammo2);
- dUserSetINT(PlayerName(playerid)).("weap3",weap3); dUserSetINT(PlayerName(playerid)).("weap3ammo",ammo3);
- dUserSetINT(PlayerName(playerid)).("weap4",weap4); dUserSetINT(PlayerName(playerid)).("weap4ammo",ammo4);
- dUserSetINT(PlayerName(playerid)).("weap5",weap5); dUserSetINT(PlayerName(playerid)).("weap5ammo",ammo5);
- dUserSetINT(PlayerName(playerid)).("weap6",weap6); dUserSetINT(PlayerName(playerid)).("weap6ammo",ammo6);
- }
- GiveSavedWeapon(playerid)
- {
- if (dUserINT(PlayerName(playerid)).("weap1")!=0)
- {
- if(weap[playerid]==0)
- {
- GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap1"), dUserINT(PlayerName(playerid)).("weap1ammo") );
- GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap2"), dUserINT(PlayerName(playerid)).("weap2ammo") );
- GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap3"), dUserINT(PlayerName(playerid)).("weap3ammo") );
- GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap4"), dUserINT(PlayerName(playerid)).("weap4ammo") );
- GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap5"), dUserINT(PlayerName(playerid)).("weap5ammo") );
- GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap6"), dUserINT(PlayerName(playerid)).("weap6ammo") );
- weap[playerid]=1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment