Код:
// This Register-Login-Saving System is by Tuntun ( Me).
// Please do not remove my credit or do not try to edit this script and post in SA-MP/Any forums without my permission.
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>
// News
new PilotJob[256];
new Float: RandMissions[][4] =
{
// Positions, (X, Y, Z and Facing Angle)
{-1331.1487,-270.7905,14.1484},
{-1331.1487,-270.7905,14.1484},
{1727.9352,-2415.5425,13.5547}
};
// defines
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
// Define the register Path.
#define PATH "Beta/Users/%s.ini"
// dialog colors
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
#define COL_MATI "{0xFF8000FF}"
#define COL_LAL "{0xFF0000FF}"
// colors
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_LIGHTGREEN 0x7FFF00
#define COLOR_DARKGREEN 0x006400
#define COLOR_LIGHTBLUE 0x91C8FF
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_GROUPTALK 0x87CEEBAA
#define COLOR_MENU 0xFFFFFFAA
#define COLOR_SYSTEM_PM 0x66CC00AA
#define COLOR_SYSTEM_PW 0xFFFF33AA
#define COLOR_MATI 0xFF8000FF
#define COLOR_RED 0xFF0000FF
// enums
enum pInfo
{
pVehicle,
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
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("Vehicle",PlayerInfo[playerid][pDeaths]);
return 1;
}
// stock
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;
}
main()
{
print("\n----------------------------------");
print(" Beta Server by Tuntun");
print("----------------------------------\n");
}
public OnGameModeInit()
{
AddStaticVehicle(519,1277.1787,1324.1875,11.7372, 0.0, 1, 1); // shamal 1
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1318.3710,1272.1166,10.9766);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
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"Register your account",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
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_Close(File);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if (killerid != INVALID_PLAYER_ID) PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}
public OnPlayerText(playerid, text[])
{
SendClientMessage(playerid,COLOR_MATI,"Please do not spam");
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 591)
{
if(PilotJob[playerid] == 1){
PilotJob[playerid] = 2;
SetPlayerCheckpoint(playerid,RandMissions[rand][0]);
SendClientMessage(playerid, -1, "Go to the {FF0000}red check-point{FFFFFF} to un-load passengers!");
return 1;
}
if(PilotJob[playerid] == 2){
PilotJob[playerid] = 3;
SetPlayerCheckpoint(playerid,RandMissions[rand][1]);
SendClientMessage(playerid, -1, "Go to the {FF0000}red check-point{FFFFFF} to un-load passengers!");
return 1;
}
if(PilotJob[playerid] ==3){
PilotJob[playerid] = 0;
SetPlayerCheckpoint(playerid,RandMissions[rand][2]);
SendClientMessage(playerid, -1, "You have earned {FF0000}2500$");
GivePlayerMoney(playerid, 2500);
SetPlayerScore(playerid, 2);
DisablePlayerCheckpoint(playerid);
return 1;
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(PilotJob[playerid] > 0)
{
PilotJob[playerid] = 0;
SendClientMessage(playerid, -1,"{FF0000}Mission has been canceled due to you exited the vehicle!");
DisablePlayerCheckpoint(playerid);
}
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, ""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_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_RED"Success!",""COL_RED"Congratulations! You are registered!!","Ok","");
}
}
case 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]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_RED"You have successfully logged in!","Ok","");
}
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 OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if (!success) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}[Error]:{FFFFFF} Wrong Command");
return 1;
}
CMD:work(playerid, params[])
{
new rand = random(sizeof(RandMissions));
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 519)
{
PilotJob[playerid] = 1;
SetPlayerCheckpoint(playerid, RandMissions[rand][0], RandMissions[rand][1],RandMissions[rand][2]);
SendClientMessage(playerid, -1, "Mission started,Go to the {FF0000}red check-point{FFFFFF} to board passangers");
}
else SendClientMessage(playerid, COLOR_RED,"{FF0000}You have to be in a flying vehicle to start a mission");
return 1;
}
CMD:gotolva(playerid,params[])
{
SetPlayerPos(playerid, 1318.3710,1272.1166,10.9766);
return 1;
}
CMD:respawn(playerid,params[])
{
SpawnPlayer(playerid);
return 1;
}
I just want to create random missions for pilot job. if i use /work than the mission will be start from sf and unload at lv. than if i use /work again the mission will be started from lv to ls. like this... i pur the coords in randommissions
Do this global and not local. new rand = random(sizeof(RandMissions));