[GameMode] Basic Pos+Guns+Helath with YSI/y_ini(Best For RP Sevrers)
#1

Basic Pos+Guns+Helath with YSI/y_ini(Best For RP Sevrers)
as per the topic says its a basic GM with a pos Health Armour and Guns Saver
i am just going to write a tutorial on it just let me come back from my school w
well try it hope you like it its a bit easy ,i am not going to explain more i will expalin how to
make one in the tutorial so i made this for a direct link of a working script, Hope its Allowed
If anythings not working Post it Here i will Fix it.
And forgot to tell that it has a Login and other's saveing system with the help of YSI/y_ini
pawn Код:
#include <a_samp>
#include <YSI\y_ini>
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/%s.ini"
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COLOR_ORANGE 0xFFA500AA
#pragma tabsize 0
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("BASE GM!-By Me");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print("BASE GM!-By Me");
    print("----------------------------------\n");
}

#endif

enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pScores,
    pRegisterd,
    Float:pPosx,
    Float:pPosy,
    Float:pPosz,
    pInt,
    pVw,
    pW1,
    pWam1,
    pW2,
    pWam2,
    pW3,
    pWam3,
    pW4,
    pWam4,
    pW5,
    pWam5,
    pW6,
    pWam6,
    pW7,
    pWam7,
    pW8,
    pWam8,
    Float:pHealth,
    Float:pArmour
}

new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Scroes",PlayerInfo[playerid][pScores]);
    INI_Int("Registerd",PlayerInfo[playerid][pRegisterd]);
    INI_Float("X",PlayerInfo[playerid][pPosx]);
    INI_Float("Y",PlayerInfo[playerid][pPosy]);
    INI_Float("Z",PlayerInfo[playerid][pPosz]);
    INI_Int("Int",PlayerInfo[playerid][pInt]);
    INI_Int("Vw",PlayerInfo[playerid][pVw]);
    INI_Int("WEAPON 1",PlayerInfo[playerid][pW1]);
    INI_Int("WEAPON AMMU 1",PlayerInfo[playerid][pWam1]);
    INI_Int("WEAPON 2",PlayerInfo[playerid][pW2]);
    INI_Int("WEAPON AMMU 2",PlayerInfo[playerid][pWam2]);
    INI_Int("WEAPON 3",PlayerInfo[playerid][pW3]);
    INI_Int("WEAPON AMMU 3",PlayerInfo[playerid][pWam3]);
    INI_Int("WEAPON 4",PlayerInfo[playerid][pW4]);
    INI_Int("WEAPON AMMU 4",PlayerInfo[playerid][pWam4]);
    INI_Int("WEAPON 5",PlayerInfo[playerid][pW5]);
    INI_Int("WEAPON AMMU 5",PlayerInfo[playerid][pWam5]);
    INI_Int("WEAPON 6",PlayerInfo[playerid][pW6]);
    INI_Int("WEAPON AMMU 6",PlayerInfo[playerid][pWam6]);
    INI_Int("WEAPON 7",PlayerInfo[playerid][pW7]);
    INI_Int("WEAPON AMMU 7",PlayerInfo[playerid][pWam7]);
    INI_Int("WEAPON 8",PlayerInfo[playerid][pW8]);
    INI_Int("WEAPON AMMU 8",PlayerInfo[playerid][pWam8]);
    INI_Float("Health",PlayerInfo[playerid][pHealth]);
    INI_Float("Armour",PlayerInfo[playerid][pArmour]);
    return 1;
}
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
    new AutoSpawn=1;
public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("base");
    AddPlayerClass(101, 1958.3783, 1343.1572, 15.3746, 269.1425, 0,0, 0,0, 0, 0);
    ShowPlayerMarkers(0);
    ShowNameTags(0);
    SetDeathDropAmount(100);
    LimitGlobalChatRadius(10.0);
    LimitPlayerMarkerRadius(100);
    AutoSpawn=1;
    return 1;
}

public OnGameModeExit()
{
    return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
GetPlayerPos(playerid,PlayerInfo[playerid][pPosx],PlayerInfo[playerid][pPosy],PlayerInfo[playerid][pPosz]);
GetPlayerWeaponData(playerid,1,PlayerInfo[playerid][pW1],PlayerInfo[playerid][pWam1]);
GetPlayerWeaponData(playerid,2,PlayerInfo[playerid][pW2],PlayerInfo[playerid][pWam2]);
GetPlayerWeaponData(playerid,3,PlayerInfo[playerid][pW3],PlayerInfo[playerid][pWam3]);
GetPlayerWeaponData(playerid,4,PlayerInfo[playerid][pW4],PlayerInfo[playerid][pWam4]);
GetPlayerWeaponData(playerid,5,PlayerInfo[playerid][pW5],PlayerInfo[playerid][pWam5]);
GetPlayerWeaponData(playerid,6,PlayerInfo[playerid][pW6],PlayerInfo[playerid][pWam6]);
GetPlayerWeaponData(playerid,7,PlayerInfo[playerid][pW7],PlayerInfo[playerid][pWam7]);
GetPlayerWeaponData(playerid,8,PlayerInfo[playerid][pW8],PlayerInfo[playerid][pWam8]);
GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);
GetPlayerArmour(playerid,PlayerInfo[playerid][pArmour]);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Scores",GetPlayerScore(playerid));
INI_WriteInt(File,"Registerd",PlayerInfo[playerid][pRegisterd]);
INI_WriteFloat(File,"X",PlayerInfo[playerid][pPosx]);
INI_WriteFloat(File,"Y",PlayerInfo[playerid][pPosy]);
INI_WriteFloat(File,"Z",PlayerInfo[playerid][pPosz]);
INI_WriteInt(File,"Int",GetPlayerInterior(playerid));
INI_WriteInt(File,"Vw",GetPlayerVirtualWorld(playerid));
INI_WriteInt(File,"WEAPON 1",PlayerInfo[playerid][pW1]);
INI_WriteInt(File,"WEAPON AMMU 1",PlayerInfo[playerid][pWam1]);
INI_WriteInt(File,"WEAPON 2",PlayerInfo[playerid][pW2]);
INI_WriteInt(File,"WEAPON AMMU 2",PlayerInfo[playerid][pWam2]);
INI_WriteInt(File,"WEAPON 3",PlayerInfo[playerid][pW3]);
INI_WriteInt(File,"WEAPON AMMU 3",PlayerInfo[playerid][pWam3]);
INI_WriteInt(File,"WEAPON 4",PlayerInfo[playerid][pW4]);
INI_WriteInt(File,"WEAPON AMMU 4",PlayerInfo[playerid][pWam4]);
INI_WriteInt(File,"WEAPON 5",PlayerInfo[playerid][pW5]);
INI_WriteInt(File,"WEAPON AMMU 5",PlayerInfo[playerid][pWam5]);
INI_WriteInt(File,"WEAPON 6",PlayerInfo[playerid][pW6]);
INI_WriteInt(File,"WEAPON AMMU 6",PlayerInfo[playerid][pWam6]);
INI_WriteInt(File,"WEAPON 7",PlayerInfo[playerid][pW7]);
INI_WriteInt(File,"WEAPON AMMU 7",PlayerInfo[playerid][pWam7]);
INI_WriteInt(File,"WEAPON 8",PlayerInfo[playerid][pW8]);
INI_WriteInt(File,"WEAPON AMMU 8",PlayerInfo[playerid][pWam8]);
INI_WriteFloat(File,"Health",PlayerInfo[playerid][pHealth]);
INI_WriteFloat(File,"Armour",PlayerInfo[playerid][pArmour]);
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
    if(AutoSpawn == 1)
    {
    if(PlayerInfo[playerid][pRegisterd] == 1){
    SetPlayerPos(playerid,PlayerInfo[playerid][pPosx],PlayerInfo[playerid][pPosy],PlayerInfo[playerid][pPosz]);
    SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][pVw]);
    SetPlayerInterior(playerid,PlayerInfo[playerid][pInt]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW1],PlayerInfo[playerid][pWam1]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW2],PlayerInfo[playerid][pWam2]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW3],PlayerInfo[playerid][pWam3]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW4],PlayerInfo[playerid][pWam4]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW5],PlayerInfo[playerid][pWam5]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW6],PlayerInfo[playerid][pWam6]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW7],PlayerInfo[playerid][pWam7]);
    GivePlayerWeapon(playerid,PlayerInfo[playerid][pW8],PlayerInfo[playerid][pWam8]);
    SetPlayerArmour(playerid,PlayerInfo[playerid][pArmour]);
    SetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);}
    else{
    }
    }
    return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
    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("/nospawn", cmdtext, true, 10) == 0))
    {
    if(AutoSpawn == 1)
    {
    SendClientMessage(playerid,COLOR_ORANGE,"Auto Spawn Disabled SuccessFully!");
    AutoSpawn = 0;
    }
    else
    {
    SendClientMessage(playerid,COLOR_ORANGE,"Auto Spawn Enabled SuccessFully!");
    AutoSpawn = 1;
    }
    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[])
{
    if(dialogid == DIALOG_REGISTER)
    {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Registerd",0);
                INI_Close(File);
            }
   }
    if(dialogid == DIALOG_LOGIN)
    {
        if ( !response ) return Kick ( playerid );
        if( response )
        {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    if(PlayerInfo[playerid][pRegisterd] == 0){
                    PlayerInfo[playerid][pRegisterd] = 1;
                    }
                    else{
                    }
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)