24.11.2014, 14:23
(
Последний раз редактировалось Jakwob; 24.11.2014 в 17:00.
)
hey i have a problem where when you die out of an event i spawns you at Blueberry farm. i have try different ways but it does not work it is ment to spawn the player after death at LS hospital. if you die in a DM it spawns you back in the deatchmatch which is what i want but when not in a deathmatch i want you to spawn a the hospital when killed.
Edit: Also i have just found out that when i leave the game and join back it saves my position but when i join back it spawns me in random positions :S help with that would be awesome. thanks
if anyone could help it would be great. i have attached the screenshots of the save position problem
Edit: if you want to experiance the problem for yourself here is my server ip: jakwobnr.hopto.org:7777
i will +rep if it works.
Thanks in advance
here is my code
Edit: Also i have just found out that when i leave the game and join back it saves my position but when i join back it spawns me in random positions :S help with that would be awesome. thanks
if anyone could help it would be great. i have attached the screenshots of the save position problem
Edit: if you want to experiance the problem for yourself here is my server ip: jakwobnr.hopto.org:7777
i will +rep if it works.
Thanks in advance
here is my code
pawn Код:
#include <a_samp>
#include <YSI\y_ini>
#include <SQLitei>
#include <sscanf2>
#include <zcmd>
#define C_R "{FF0000}"
#define C_G "{AFAFAF}"
#define C_Y "{FFFF00}"
#define C_W "{FFFFFF}"
#define C_LB "{33CCFF}"
#define C_P "{FF00FF}"
#define UserPath "Accounts/%s.ini"
enum
{
DIALOG_LOGIN,
DIALOG_REGISTER,
DIALOG_BANNED,
DIALOG_ADMINCMDS,
DIALOG_FEATURE,
DIALOG_HELP,
DIALOG_COMMANDS,
DIALOG_LSWDM,
DIALOG_LSCDM,
DIALOG_AREA69DM
}
new Float: DM1RandomSpawns[][3] =// LSW DM
{
{2139.0374,-2289.7983,20.6646},
{2143.6794,-2248.2222,20.6641},
{2170.9897,-2245.7261,20.1587},
{2178.2705,-2250.8745,20.6719},
{2177.0288,-2250.5259,13.3041},
{2158.2756,-2232.3232,13.3076}
};
new Float: DM2RandomSpawns[][3] =// LSC DM
{
{2802.1389,-1467.5292,16.2231},
{2798.9922,-1467.0610,20.2188},
{2798.4775,-1466.8619,24.1875},
{2798.3718,-1467.1946,28.1563},
{2798.5645,-1467.1703,32.1250},
{2798.0889,-1467.0990,36.0938}
};
new Float: AREA69DMRandomSpawns[][3] =// AREA 69 DM
{
{217.4204,1861.0787,13.1406},
{266.2121,1894.7869,25.4985},
{153.3800,1846.0709,17.6406},
{106.7296,1897.5729,18.3774}
};
enum PlayerInfo //Player Information
{
Pass[129],
Adminlevel,
Money,
Scores,
Kills,
Deaths,
Skin,
DMkills,
Registered,
Float: Health,
Float: Armour,
Float: PosX,
Float: PosY,
Float: PosZ,
Float: Angle,
Interior,
VirtualWorld,
Wep0,
Wep1,
Wep2,
Wep3,
Wep4,
Wep5,
Wep6,
Wep7,
Wep8,
Wep9,
Wep10,
Wep11,
Wep12,
Ammo0,
Ammo1,
Ammo2,
Ammo3,
Ammo4,
Ammo5,
Ammo6,
Ammo7,
Ammo8,
Ammo9,
Ammo10,
Ammo11,
Ammo12
}
new pInfo[MAX_PLAYERS][PlayerInfo];
new DB:bans; //------[BANNING]------
new ID;
new FirstSpawn;
new Wasted;
new LSWDM[MAX_PLAYERS];// LSW DM
new LSCDM[MAX_PLAYERS];// LSC DM
new AREA69DM[MAX_PLAYERS];// AREA 69 DM
new LSWDMPickup;// LSW DM
new LSCDMPickup;// LSC DM
new AREA69DMPickup;// Area 69 DM
native WP_Hash(buffer[],len,const str[]);
main()
{
}
public OnGameModeInit()
{
bans = db_open("BansList.db"); //------[BANNING]------
db_query(bans, "CREATE TABLE IF NOT EXISTS `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`)"); //------[BANNING]------
LSWDMPickup = CreatePickup(1254, 2, 2184.4358,-2251.9446,14.7700, -1);// LSW DM [FIX]
LSCDMPickup = CreatePickup(1254, 2, 2820.1062,-1474.3727,16.2500, -1);// LSC DM
LSCDMPickup = CreatePickup(1254, 2, 986.8483,-1335.4131,13.5469, -1);// AREA 69 DM
CreateObject(3037, 2177.81055, -2255.67993, 15.91000, 0.00000, 0.00000, -45.00000);// LSW DM
CreateObject(2957, 2118.47876, -2274.90356, 21.24450, 0.00000, 0.00000, -45.00000);// LSW DM
DisableInteriorEnterExits();
EnableStuntBonusForAll(0);
ShowNameTags(1);
SetNameTagDrawDistance(10.0);
UsePlayerPedAnims();
SetGameModeText("Jakwobs Gamemode");
return 1;
}
public OnGameModeExit()
{
db_close(bans); //------[BANNING]------
return 1;
}
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129);
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);
INI_Int("Money",pInfo[playerid][Money]);
INI_Int("Scores",pInfo[playerid][Scores]);
INI_Int("Kills",pInfo[playerid][Kills]);
INI_Int("Deaths",pInfo[playerid][Deaths]);
INI_Int("Skin",pInfo[playerid][Skin]);
INI_Int("DMkills",pInfo[playerid][DMkills]);
INI_Int("Registered",pInfo[playerid][Registered]);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(fexist(Path(playerid)))
{
pInfo[playerid][PosX] = 0.0;
pInfo[playerid][PosX] = 0.0;
pInfo[playerid][PosX] = 0.0;
pInfo[playerid][PosX] = 0.0;
pInfo[playerid][PosX] = 0;
pInfo[playerid][PosX] = 0;
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");
}
else
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
return 1;
}
new Query[98], DBResult:Result; //------[BANNING]------
format(Query, sizeof(Query), "SELECT * FROM `BANNED` WHERE `NAME` = '%s' OR `IP` = '%s'", DB_Escape(GetName(playerid)), DB_Escape(PlayerIP(playerid))); //------[BANNING]------
Result = db_query(bans, Query); //------[BANNING]------
if(db_num_rows(Result)) //------[BANNING]------
{
new banreason[50], bannedby[24], banname[24], banip[18], string[300];
db_get_field_assoc(Result, "REASON", banreason, sizeof(banreason)); db_get_field_assoc(Result, "ADMIN", bannedby, sizeof(bannedby));
db_get_field_assoc(Result, "NAME", banname, sizeof(banname)); db_get_field_assoc(Result, "IP", banip, sizeof(banip));
format(string, sizeof(string), ""C_W"Our system has detected that your username or IP is "C_R"banned"C_W".\nBanned Name: "C_G"%s\n"C_W"Banned IP: "C_G"%s\n"C_W"Banned by: "C_G"%s\n"C_W"Reason: "C_G"%s\n"C_P"* "C_W"If you wish to be unbanned, contact the server owner.", banname, banip, bannedby, banreason);
ShowPlayerDialog(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, ""C_R"Banned", string, "Close", ""), string = "\0";
printf("%s has been kicked from OnPlayerConnect - Username ban detection", GetName(playerid));
SetTimerEx("KickTimer", 75, false, "i", playerid);
db_free_result(Result);
string = "\0";
}
LSWDM[playerid] = 0;// LSW DM
LSCDM[playerid] = 0;// LSC DM
SetPlayerMapIcon(playerid, 2, 2184.4978,-2251.9897,14.7700, 23, 0);// LSW DM
SetPlayerMapIcon(playerid, 3, 2820.1062,-1474.3727,16.2500, 23, 0);// LSC DM
SetPlayerMapIcon(playerid, 4, 986.8483,-1335.4131,13.5469, 23, 0);// AREA 69 DM
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SavePlayerInfo(playerid);
LSWDM[playerid] = 0;// LSW DM
LSWDM[playerid] = 0;// LSC DM
AREA69DM[playerid] = 0;// AREA 69 DM
return 1;
}
public OnPlayerSpawn(playerid)
{
if(LSWDM[playerid] == 1)// LSW DM
{
new DM1rand = random(sizeof(DM1RandomSpawns));
SetPlayerPos(playerid, DM1RandomSpawns[DM1rand][0], DM1RandomSpawns[DM1rand][1],DM1RandomSpawns[DM1rand][2]);
SetPlayerVirtualWorld(playerid, -1);
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
}
if(LSCDM[playerid] == 1)// LSC DM
{
new DM2rand = random(sizeof(DM2RandomSpawns));
SetPlayerPos(playerid, DM2RandomSpawns[DM2rand][0], DM2RandomSpawns[DM2rand][1],DM2RandomSpawns[DM2rand][2]);
SetPlayerVirtualWorld(playerid, -1);
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
}
if(AREA69DM[playerid] == 1)// AREA 69 DM
{
new DM3rand = random(sizeof(AREA69DMRandomSpawns));
SetPlayerPos(playerid, AREA69DMRandomSpawns[DM3rand][0], AREA69DMRandomSpawns[DM3rand][1],AREA69DMRandomSpawns[DM3rand][2]);
SetPlayerVirtualWorld(playerid, -1);
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
}
if(Wasted == 1) // Hospital spawn
{
SetPlayerPos(playerid, 2038.4070,-1411.5172,17.1641);
SetPlayerFacingAngle(playerid, 129.3782);
Wasted = 0;
}
if(pInfo[playerid][Registered] == 1)
{
SetPlayerPos(playerid, pInfo[playerid][PosX], pInfo[playerid][PosY], pInfo[playerid][PosZ]);
SetPlayerFacingAngle(playerid,pInfo[playerid][Angle]);
SetPlayerInterior(playerid,pInfo[playerid][Interior]);
SetPlayerVirtualWorld(playerid,pInfo[playerid][VirtualWorld]);
SetPlayerSkin(playerid,pInfo[playerid][Skin]);
if(pInfo[playerid][Wep0]!=0 && pInfo[playerid][Ammo0]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep0],pInfo[playerid][Ammo0]);
if(pInfo[playerid][Wep1]!=0 && pInfo[playerid][Ammo1]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep1],pInfo[playerid][Ammo1]);
if(pInfo[playerid][Wep2]!=0 && pInfo[playerid][Ammo2]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep2],pInfo[playerid][Ammo2]);
if(pInfo[playerid][Wep3]!=0 && pInfo[playerid][Ammo3]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep3],pInfo[playerid][Ammo3]);
if(pInfo[playerid][Wep4]!=0 && pInfo[playerid][Ammo4]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep4],pInfo[playerid][Ammo4]);
if(pInfo[playerid][Wep5]!=0 && pInfo[playerid][Ammo5]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep5],pInfo[playerid][Ammo5]);
if(pInfo[playerid][Wep6]!=0 && pInfo[playerid][Ammo6]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep6],pInfo[playerid][Ammo6]);
if(pInfo[playerid][Wep7]!=0 && pInfo[playerid][Ammo7]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep7],pInfo[playerid][Ammo7]);
if(pInfo[playerid][Wep8]!=0 && pInfo[playerid][Ammo8]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep8],pInfo[playerid][Ammo8]);
if(pInfo[playerid][Wep9]!=0 && pInfo[playerid][Ammo9]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep9],pInfo[playerid][Ammo9]);
if(pInfo[playerid][Wep10]!=0 && pInfo[playerid][Ammo10]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep10],pInfo[playerid][Ammo10]);
if(pInfo[playerid][Wep11]!=0 && pInfo[playerid][Ammo11]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep11],pInfo[playerid][Ammo11]);
if(pInfo[playerid][Wep12]!=0 && pInfo[playerid][Ammo12]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep12],pInfo[playerid][Ammo12]);
}
if(pInfo[playerid][Registered] == 1 && FirstSpawn == 1)
{
SetPlayerPos(playerid, 1682.7000,-2244.8999,13.5454);
SetPlayerFacingAngle(playerid, 178.9000);
SetPlayerSkin(playerid, 29);
GivePlayerMoney(playerid, 1000);
FirstSpawn = 0;
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(LSWDM[playerid] == 1)// LSW DM
{
GivePlayerMoney(killerid, 300);
SendClientMessage(killerid, -1, ""C_W"You recieved $300 for killing in a DM");
pInfo[killerid][DMkills] ++;
pInfo[killerid][Scores]++;
pInfo[killerid][Kills]++;
}
if(LSCDM[playerid] == 1)// LSC DM
{
GivePlayerMoney(killerid, 300);
SendClientMessage(killerid, -1, ""C_W"You recieved $300 for killing in a DM");
pInfo[killerid][DMkills] ++;
pInfo[killerid][Scores]++;
pInfo[killerid][Kills]++;
}
if(AREA69DM[playerid] == 1)// LSC DM
{
GivePlayerMoney(killerid, 300);
SendClientMessage(killerid, -1, ""C_W"You recieved $300 for killing in a DM");
pInfo[killerid][DMkills] ++;
pInfo[killerid][Scores]++;
pInfo[killerid][Kills]++;
}
pInfo[killerid][Scores]++;
pInfo[killerid][Kills]++;
pInfo[playerid][Deaths]++;
Wasted = 1;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file,"AdminLevel",0);
INI_WriteInt(file,"Money",0);
INI_WriteInt(file,"Scores",0);
INI_WriteInt(file,"Kills",0);
INI_WriteInt(file,"Deaths",0);
INI_WriteInt(file,"Skin",0);
INI_WriteInt(file,"DMkills",0);
INI_WriteInt(file,"Registered",0);
INI_Close(file);
SendClientMessage(playerid,-1,""C_W"You have been successfully registered");
SendClientMessage(playerid,-1," ");
SendClientMessage(playerid,-1," ");
SendClientMessage(playerid, -1, ""C_W"Welcome to Never Rest Freeplay");
SendClientMessage(playerid, -1, ""C_W"Our records show you are new to the server.");
SendClientMessage(playerid, -1, ""C_W"Here out the basic commands to get you started.");
SendClientMessage(playerid, -1, ""C_LB"/feature "C_W"to see all the features in the server");
SendClientMessage(playerid, -1, ""C_LB"/help "C_W"to see our help dialog");
SendClientMessage(playerid, -1, ""C_LB"/commands "C_W"to see all the commands in this server");
SendClientMessage(playerid, -1, ""C_W"Enjoy your stay and visit "C_LB"www.nr-freeplay.esy.es");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, ""C_W"You have been given $1000 for joining the server.");
/*SetPlayerPos(playerid, 1682.7000,-2244.8999,13.5454);
SetPlayerFacingAngle(playerid, 178.9000);
SetPlayerSkin(playerid, 29);*/
FirstSpawn = 1;
pInfo[playerid][Registered] = 1;
return 1;
}
}
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass, pInfo[playerid][Pass], false))
{
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
/*if ( pInfo[playerid][PosX] != 0.0 && pInfo[playerid][PosY] != 0.0 &&pInfo[playerid][PosZ] != 0.0 && pInfo[playerid][Angle] != 0.0 )
{
SetPlayerPos(playerid, pInfo[playerid][PosX], pInfo[playerid][PosY], pInfo[playerid][PosZ]);
SetPlayerFacingAngle(playerid,pInfo[playerid][Angle]);
SetPlayerInterior(playerid,pInfo[playerid][Interior]);
SetPlayerVirtualWorld(playerid,pInfo[playerid][VirtualWorld]);
if(pInfo[playerid][Wep0]!=0 && pInfo[playerid][Ammo0]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep0],pInfo[playerid][Ammo0]);
if(pInfo[playerid][Wep1]!=0 && pInfo[playerid][Ammo1]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep1],pInfo[playerid][Ammo1]);
if(pInfo[playerid][Wep2]!=0 && pInfo[playerid][Ammo2]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep2],pInfo[playerid][Ammo2]);
if(pInfo[playerid][Wep3]!=0 && pInfo[playerid][Ammo3]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep3],pInfo[playerid][Ammo3]);
if(pInfo[playerid][Wep4]!=0 && pInfo[playerid][Ammo4]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep4],pInfo[playerid][Ammo4]);
if(pInfo[playerid][Wep5]!=0 && pInfo[playerid][Ammo5]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep5],pInfo[playerid][Ammo5]);
if(pInfo[playerid][Wep6]!=0 && pInfo[playerid][Ammo6]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep6],pInfo[playerid][Ammo6]);
if(pInfo[playerid][Wep7]!=0 && pInfo[playerid][Ammo7]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep7],pInfo[playerid][Ammo7]);
if(pInfo[playerid][Wep8]!=0 && pInfo[playerid][Ammo8]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep8],pInfo[playerid][Ammo8]);
if(pInfo[playerid][Wep9]!=0 && pInfo[playerid][Ammo9]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep9],pInfo[playerid][Ammo9]);
if(pInfo[playerid][Wep10]!=0 && pInfo[playerid][Ammo10]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep10],pInfo[playerid][Ammo10]);
if(pInfo[playerid][Wep11]!=0 && pInfo[playerid][Ammo11]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep11],pInfo[playerid][Ammo11]);
if(pInfo[playerid][Wep12]!=0 && pInfo[playerid][Ammo12]!=0) GivePlayerWeapon(playerid,pInfo[playerid][Wep12],pInfo[playerid][Ammo12]);
}*/
SetPlayerScore(playerid,pInfo[playerid][Scores]);
GivePlayerMoney(playerid,pInfo[playerid][Money]);
SetPlayerSkin(playerid,pInfo[playerid][Skin]);
SendClientMessage(playerid,-1,""C_W"Welcome back! You have successfully logged in");
if (pInfo[playerid][Adminlevel] < 1) return 0;
{
new stringa[128];
format(stringa,sizeof(stringa),""C_W"Your Admin Level: "C_LB"%d",pInfo[playerid][Adminlevel]);
SendClientMessage(playerid, -1, stringa);
}
}
else
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
return 1;
}
}
}
if(dialogid == DIALOG_LSWDM)// LSW DM
{
if(response)
{
new DM1rand = random(sizeof(DM1RandomSpawns)), str[128],pName[MAX_PLAYER_NAME];
SetPlayerPos(playerid, DM1RandomSpawns[DM1rand][0], DM1RandomSpawns[DM1rand][1],DM1RandomSpawns[DM1rand][2]);
SetPlayerVirtualWorld(playerid, -1);
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
GetPlayerName(playerid,pName,sizeof(pName));
format(str, sizeof(str), ""C_G"%s "C_W"Has joined LS Warehouse Deathhmatch", pName);
SendClientMessageToAll(-1, str);
SendClientMessage(playerid, -1, ">> To leave the deathmatch use /leave");
LSWDM[playerid] = 1;
}
else
{
SendClientMessage(playerid, -1, ">> Deathmatch declined");
}
return 1;
}
if(dialogid == DIALOG_LSCDM)// LSW DM
{
if(response)
{
new DM2rand = random(sizeof(DM2RandomSpawns)), str[128],pName[MAX_PLAYER_NAME];
SetPlayerPos(playerid, DM2RandomSpawns[DM2rand][0], DM2RandomSpawns[DM2rand][1],DM2RandomSpawns[DM2rand][2]);
SetPlayerVirtualWorld(playerid, -1);
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
GetPlayerName(playerid,pName,sizeof(pName));
format(str, sizeof(str), ""C_G"%s "C_W"Has joined LS Car Park Deathhmatch", pName);
SendClientMessageToAll(-1, str);
SendClientMessage(playerid, -1, ""C_W"To leave the deathmatch use "C_LB"/leave");
LSCDM[playerid] = 1;
}
else
{
SendClientMessage(playerid, -1, ""C_W"Deathmatch declined");
}
return 1;
}
if(dialogid == DIALOG_AREA69DM)// LSW DM
{
if(response)
{
new DM3rand = random(sizeof(AREA69DMRandomSpawns)), str[128],pName[MAX_PLAYER_NAME];
SetPlayerPos(playerid, AREA69DMRandomSpawns[DM3rand][0], AREA69DMRandomSpawns[DM3rand][1],AREA69DMRandomSpawns[DM3rand][2]);
SetPlayerVirtualWorld(playerid, -1);
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
GetPlayerName(playerid,pName,sizeof(pName));
format(str, sizeof(str), ""C_G"%s "C_W"Has joined LV Area 69 Deathhmatch", pName);
SendClientMessageToAll(-1, str);
SendClientMessage(playerid, -1, ""C_W"To leave the deathmatch use "C_LB"/leave");
AREA69DM[playerid] = 1;
}
else
{
SendClientMessage(playerid, -1, ""C_W"Deathmatch declined");
}
return 1;
}
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == LSWDMPickup)// LSW DM
{
ShowPlayerDialog(playerid, DIALOG_LSWDM, DIALOG_STYLE_MSGBOX, "LS Warehouse Deathhmatch", "Are you sure you want to join the DM?", "Join", "Close");
}
if(pickupid == LSCDMPickup)// LSW DM
{
ShowPlayerDialog(playerid, DIALOG_LSCDM, DIALOG_STYLE_MSGBOX, "LS Car Park Deathhmatch", "Are you sure you want to join the DM?", "Join", "Close");
}
if(pickupid == AREA69DMPickup)// LSW DM
{
ShowPlayerDialog(playerid, DIALOG_AREA69DM, DIALOG_STYLE_MSGBOX, "LV Area 69 Deathhmatch", "Are you sure you want to join the DM?", "Join", "Close");
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID && bodypart == 9)
{
SetPlayerHealth(playerid, 0.0);
GameTextForPlayer(playerid, "You Took A~n~Headshot", 5000, 2);
}
return 1;
}
CMD:commands(playerid, params[])
{
new str[300], str1[1000];
format(str, sizeof(str), ""C_Y">> "C_W"/die - Kill yourself\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"/help - Get help within the server\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"/feature - See the complete list of features\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"/leave - Leave a deathmatch or event\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"More to come\n");
strcat(str1, str);
ShowPlayerDialog(playerid, DIALOG_COMMANDS, DIALOG_STYLE_MSGBOX, "Commands", str1, "Close", "");
return 1;
}
CMD:feature(playerid, params[])
{
new str[300], str1[1000];
format(str, sizeof(str), "| Add Date: 21/11/2014 | Name: Headshot | Description: Headshots = instant kills\n");
strcat(str1, str);
format(str, sizeof(str), "| Add Date: 22/11/2014 | Name: Accounts | Description: Fully saving account system\n");
strcat(str1, str);
format(str, sizeof(str), "| Add Date: 22/11/2014 | Name: Admin | Description: Admin system\n");
strcat(str1, str);
format(str, sizeof(str), "| Add Date: 22/11/2014 | Name: Ban sys | Description: Fully saving ban/unban system\n");
strcat(str1, str);
format(str, sizeof(str), "| Add Date: 23/11/2014 | Name: DM sys | Description: Currently 2 Deathmatches in the server\n");
strcat(str1, str);
ShowPlayerDialog(playerid, DIALOG_FEATURE, DIALOG_STYLE_MSGBOX, "Server Features", str1, "Close", "");
return 1;
}
CMD:help(playerid, params[])
{
new str[300], str1[1000];
format(str, sizeof(str), ""C_W"How to make money?\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"Killing other players while not in an a event will get you a minimum score and a bonus of $50\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"Enter one of our many Deathmatches and continue to kill to gain the best money.\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"Sell you vehicle to the chop shop\n");
strcat(str1, str);
format(str, sizeof(str), ""C_Y">> "C_W"Doing Minijob e.g. pizza boy or bus driver\n");
strcat(str1, str);
ShowPlayerDialog(playerid, DIALOG_HELP, DIALOG_STYLE_MSGBOX, "Help", str1, "Close", "Next");
return 1;
}
CMD:leave(playerid, params[])
{
if(LSWDM[playerid] == 1)
{
LSWDM[playerid] = 0;
SetPlayerPos(playerid, 2182.8616,-2258.8660,13.3840);
SetPlayerVirtualWorld(playerid, 0);
SendClientMessage(playerid, -1, ""C_W"You have left the deathmatch");
}
if(LSCDM[playerid] == 1)
{
LSCDM[playerid] = 0;
SetPlayerPos(playerid, 2808.9141,-1472.8516,16.7080);
SetPlayerVirtualWorld(playerid, 0);
SendClientMessage(playerid, -1, ""C_W"You have left the deathmatch");
}
if(AREA69DM[playerid] == 1)
{
LSCDM[playerid] = 0;
SetPlayerPos(playerid, 986.3855,-1384.8246,13.6178);
SetPlayerVirtualWorld(playerid, 0);
SendClientMessage(playerid, -1, ""C_W"You have left the deathmatch");
}
return 1;
}
CMD:die(playerid, params[])
{
SendClientMessage(playerid, -1, ""C_R"Killed yourself!");
SetPlayerHealth(playerid, 0.1);
return 1;
}
//---------| LEVEL 1 |---------
CMD:acmds(playerid, params[])
{
new str[300], str1[1000];
if (pInfo[playerid][Adminlevel] >= 1)
{
format(str, sizeof(str), ""C_P"> Level 1 <\n");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/acmds "C_G"- Admin commands\n");
strcat(str1, str);
//format(str, sizeof(str), ""C_W"/spec "C_G"- Spectate a player\n");
//strcat(str1, str);
}
if (pInfo[playerid][Adminlevel] >= 2)
{
format(str, sizeof(str), ""C_P"> Level 2 <\n");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/ban "C_G"- Ban an online player\n");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/offlineban "C_G"- Ban a offline player\n");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/banned "C_G"- Check if a players name is banned\n");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/unban "C_G"- Unban a player\n");
strcat(str1, str);
}
if (pInfo[playerid][Adminlevel] >= 3)
{
format(str, sizeof(str), ""C_P"> Level 3 <\n");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/setadmin "C_G"- Set a player admin\n");
strcat(str1, str);
//format(str, sizeof(str), ""C_W"/no "C_G"- say no to world");
//strcat(str1, str);
}
/*if (pInfo[playerid][Adminlevel] >= 4)
{
format(str, sizeof(str), ""C_PINK"Level 4\n");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/what "C_G"- what the fuck");
strcat(str1, str);
format(str, sizeof(str), ""C_W"/die "C_G"- kill a nigga\n");
strcat(str1, str);
}*/
ShowPlayerDialog(playerid, DIALOG_ADMINCMDS, DIALOG_STYLE_MSGBOX, "Admin Commands", str1, "Close", "");
return 1;
}
//---------| LEVEL 2 |---------
CMD:ban(playerid, params[]) {
new reason[48];
if(pInfo[playerid][Adminlevel] < 1) return 0;
if(sscanf(params, "us[48]", ID, reason)) return SendClientMessage(playerid, -1, ""C_W"/ban <playerid> <reason>");
if(ID == INVALID_PLAYER_ID || !IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, ""C_W"Invalid ID");
BanWithReason(playerid, ID, reason);
return 1;
}
CMD:offlineban(playerid, params[]) {
new Query[240], string[212], pName[24], reason[100], DBResult:result, day, month, year, second, minute, hour, datestring[24], timestring[24];
if(pInfo[playerid][Adminlevel] < 1) return 0;
if(sscanf(params, "s[24]s[48]", pName, reason)) return SendClientMessage(playerid, -1, ""C_W"/offlineban <playername> <reason>");
format(Query, sizeof(Query), "SELECT `NAME` FROM `BANNED` WHERE `NAME` = '%s'", pName);
result = db_query(bans, Query);
if(!db_num_rows(result))
{
getdate(day, month, year), gettime(hour, minute, second);
format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year), format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '0', '%s', '%s', '%s', '%s')", DB_Escape(pName), reason, DB_Escape(GetName(playerid)), datestring, timestring);
result = db_query(bans, Query);
if(result)
{
format(string, sizeof(string), ""C_G"%s "C_W"has been banned by "C_G"%s(%d)"C_W". Reason: "C_G"%s", pName, GetName(playerid), playerid, reason);
SendClientMessageToAll(-1, string), string = "\0";
printf("[ban] [%s]: offlinebanned %s. reason: %s", GetName(playerid), pName, reason);
}
else
{
format(string, sizeof(string), ""C_W"Failed to ban '%s'..", pName), SendClientMessage(playerid, -1, string);
printf("[ban] [%s]: failed to offlineban %s. reason %s", GetName(playerid), pName, reason);
}
}
else return SendClientMessage(playerid, -1, ""C_W"That username is already banned!");
db_free_result(result);
return 1;
}
CMD:banned(playerid, params[])
{
if(pInfo[playerid][Adminlevel] < 1) return 0;
else if(isnull(params)) return SendClientMessage(playerid, -1, ""C_W"/searchban <playername>");
else
{
new Query[240], string[180];
format(Query, sizeof(Query), "SELECT * FROM `BANNED` WHERE `NAME` LIKE '%%%s%%' OR `IP` LIKE '%%%s%%' ORDER BY `DATE` DESC LIMIT 6", params, params);
new DBResult:Result = db_query(bans, Query);
if(db_num_rows(Result))
{
new BannedBy[MAX_PLAYER_NAME], BannedName[MAX_PLAYER_NAME], BannedIP[MAX_PLAYER_NAME], BannedReason[MAX_PLAYER_NAME*2];
do
{
db_get_field_assoc(Result, "NAME", BannedName, sizeof(BannedName));
db_get_field_assoc(Result, "IP", BannedIP, sizeof(BannedIP));
db_get_field_assoc(Result, "ADMIN", BannedBy, sizeof(BannedBy));
db_get_field_assoc(Result, "REASON", BannedReason, sizeof(BannedReason));
format(string, sizeof(string), ""C_G"%s(IP: %s) "C_W"- banned by "C_G"%s "C_W"- reason: "C_G"%s", BannedName, BannedIP, BannedBy, BannedReason);
SendClientMessage(playerid, -1, string);
}
while(db_next_row(Result));
}
else SendClientMessage(playerid, -1, ""C_W"No bans found!");
db_free_result(Result);
string = "\0", Query = "\0";
}
return 1;
}
CMD:unban(playerid, params[]) {
new pName[24], reason[50], Query[132], DBResult:Result;
new stringz[92];
if(pInfo[playerid][Adminlevel] < 1) return 0;
if(sscanf(params, "s[24]s[50]", pName, reason)) return SendClientMessage(playerid, -1, ""C_W"/unban <name> <reason>");
format(Query, sizeof(Query), "SELECT * FROM `BANNED` WHERE `NAME` = '%s'", pName);
Result = db_query(bans, Query);
if(db_num_rows(Result))
{
format(Query, sizeof(Query), "DELETE FROM `BANNED` WHERE `NAME` = '%s'", pName);
Result = db_query(bans, Query);
format(stringz, sizeof(stringz), ""C_G"%s "C_W"has been unbanned by "C_G"%s"C_W". Reason: "C_G"%s", GetName(playerid), pName, reason);
SendClientMessageToAll(-1, stringz), stringz = "\0";
}
else SendClientMessage(playerid, -1, ""C_W"No bans found on that user-name!");
stringz = "\0", Query = "\0", reason = "\0";
db_free_result(Result);
return 1;
}
//---------| LEVEL 3 |---------
CMD:setadmin(playerid, params[])
{
new levels, Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str2[128];
if(pInfo[playerid][Adminlevel] < 3)return 0;
if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,-1, ""C_W"/setadmin <ID> <Level 1-3>");
if(levels > 3) return SendClientMessage(playerid,-1,""C_W"Levels available 1-3!");
if(!IsPlayerConnected(ID))return SendClientMessage(playerid,-1,""C_W"Player is not connected.");
if(pInfo[ID][Adminlevel] == levels) return SendClientMessage(playerid,-1, ""C_W"Player already this level!");
GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
GetPlayerName(ID,pname,MAX_PLAYER_NAME);
if(levels == 0)
{
format(str2, sizeof(str2),""C_G"%s "C_W"has set your Admin level to "C_G"%d.",Nam,levels);
SendClientMessage(ID,-1,str2);
format(str2, sizeof(str2),""C_W"You have set "C_G"%s "C_W"Admin level to "C_G"%d!",pname,levels);
SendClientMessage(playerid,-1,str2);
pInfo[ID][Adminlevel] = levels;
return 1;
}
format(str2, sizeof(str2),""C_G"%s "C_W"has set your Admin level to "C_G"%d.",Nam,levels);
SendClientMessage(ID,-1,str2);
format(str2, sizeof(str2),""C_W"You have set "C_G"%s "C_W"Admin level to "C_G"%d!",pname,levels);
SendClientMessage(playerid,-1,str2);
pInfo[ID][Adminlevel] = levels;
return 1;
}
//---------| LEVEL RCON |---------
CMD:adminlvl(playerid, params[])
{
new levels, Nam[MAX_PLAYER_NAME],str2[128];
if(!IsPlayerAdmin(playerid))return 0;
if(sscanf(params,"i",levels)) return SendClientMessage(playerid,-1, ""C_W"/adminlvl <Level 1-4>");
if(levels > 4) return SendClientMessage(playerid,-1,""C_W"Levels available 1-4!");
if(pInfo[playerid][Adminlevel] == levels) return SendClientMessage(playerid,-1, ""C_W"You are already this level!");
GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
if(levels == 0)
{
format(str2, sizeof(str2),""C_W"You have set your level to "C_G"%d!",levels);
SendClientMessage(playerid,-1,str2);
pInfo[ID][Adminlevel] = levels;
return 1;
}
format(str2, sizeof(str2),""C_W"You have set your level to "C_G"%d!",levels);
SendClientMessage(playerid,-1,str2);
pInfo[ID][Adminlevel] = levels;
return 1;
}
/*-----------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------| STOCK SECTION |--------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------*/
stock Path(playerid)
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),UserPath,name);
return str;
}
stock SavePlayerInfo(playerid)
{
GetPlayerPos(playerid, pInfo[playerid][PosX], pInfo[playerid][PosY], pInfo[playerid][PosZ]);
GetPlayerFacingAngle(playerid, pInfo[playerid][Angle]);
new skin = GetPlayerSkin(playerid);
new weapons[13][2];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
INI_WriteInt(file,"Skin",skin);
INI_WriteInt(file,"DMkills",pInfo[playerid][DMkills]);
INI_WriteInt(file,"Registered",pInfo[playerid][Registered]);
INI_WriteFloat(file, "PosX",pInfo[playerid][PosX]);
INI_WriteFloat(file, "PosY",pInfo[playerid][PosY]);
INI_WriteFloat(file, "PosZ",pInfo[playerid][PosZ]);
INI_WriteFloat(file, "Angle",pInfo[playerid][Angle]);
INI_WriteInt(file, "Interior",pInfo[playerid][Interior]);
INI_WriteInt(file, "VirtualWorld",pInfo[playerid][VirtualWorld]);
INI_WriteInt(file,"Wep0",weapons[0][0]);
INI_WriteInt(file,"Wep1",weapons[1][0]);
INI_WriteInt(file,"Wep2",weapons[2][0]);
INI_WriteInt(file,"Wep3",weapons[3][0]);
INI_WriteInt(file,"Wep4",weapons[4][0]);
INI_WriteInt(file,"Wep5",weapons[5][0]);
INI_WriteInt(file,"Wep6",weapons[6][0]);
INI_WriteInt(file,"Wep7",weapons[7][0]);
INI_WriteInt(file,"Wep8",weapons[8][0]);
INI_WriteInt(file,"Wep9",weapons[9][0]);
INI_WriteInt(file,"Wep10",weapons[10][0]);
INI_WriteInt(file,"Wep11",weapons[11][0]);
INI_WriteInt(file,"Wep12",weapons[12][0]);
INI_WriteInt(file,"Ammo0",weapons[0][1]);
INI_WriteInt(file,"Ammo1",weapons[1][1]);
INI_WriteInt(file,"Ammo2",weapons[2][1]);
INI_WriteInt(file,"Ammo3",weapons[3][1]);
INI_WriteInt(file,"Ammo4",weapons[4][1]);
INI_WriteInt(file,"Ammo5",weapons[5][1]);
INI_WriteInt(file,"Ammo6",weapons[6][1]);
INI_WriteInt(file,"Ammo7",weapons[7][1]);
INI_WriteInt(file,"Ammo8",weapons[8][1]);
INI_WriteInt(file,"Ammo9",weapons[9][1]);
INI_WriteInt(file,"Ammo10",weapons[10][1]);
INI_WriteInt(file,"Ammo11",weapons[11][1]);
INI_WriteInt(file,"Ammo12",weapons[12][1]);
INI_Close(file);
return 1;
}
stock BanWithReason(playerid = INVALID_PLAYER_ID, targetid, reason[]) //------[BANNING]------
{
new Query[240], string[112], DBResult:result, day, month, year, second, minute, hour, datestring[24], timestring[24];
getdate(day, month, year);
gettime(hour, minute, second);
format(datestring, sizeof(datestring), "%i-%i-%i", day, month, year);
format(timestring, sizeof(timestring), "%i:%i:%i", hour, minute, second);
if(playerid != INVALID_PLAYER_ID)
{
format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", DB_Escape(GetName(targetid)), DB_Escape(PlayerIP(targetid)), reason, DB_Escape(GetName(playerid)), datestring, timestring);
result = db_query(bans, Query);
if(result)
{
format(string, sizeof(string), ""C_G"%s(%d) "C_W"has been banned by "C_G"%s(%d)"C_W". Reason "C_G"%s", GetName(targetid), targetid, GetName(playerid), playerid, reason);
SendClientMessageToAll(-1, string), string = "\0";
printf("[ban] [%s]: successfully added %s's ban info", GetName(playerid), GetName(targetid));
}
else
{
format(string, sizeof(string), ""C_W"failed to ban '%s'", GetName(targetid));
SendClientMessageToAll(-1, string), string = "\0";
printf("[ban] [%s]: failed to add %s's ban info", GetName(playerid), GetName(targetid));
}
}
/*
else
{
format(Query, sizeof(Query), "INSERT INTO `BANNED` (`NAME`, `IP`, `REASON`, `ADMIN`, `DATE`, `TIME`) VALUES ('%s', '%s', '%s', 'Server', '%s', '%s')", DB_Escape(GetName(targetid)), DB_Escape(PlayerIP(targetid)), reason, datestring, timestring);
result = db_query(bans, Query);
format(string, sizeof(string), "BAN: %s(%d) has been banned by the Server due to %s", GetName(targetid), targetid, reason);
SendClientMessageToAll(COLOR_RED, string), string = "\0";
}
for anti-cheat purposes ^
*/
Query = "\0", db_free_result(result);
SetTimerEx("KickTimer", 100, false, "i", targetid);
}
stock DB_Escape(text[]) //------[BANNING]------
{
new
ret[80 * 2],
ch,
i,
j
;
while ((ch = text[i++]) && j < sizeof (ret))
{
if (ch == '\'')
{
if (j < sizeof (ret) - 2)
{
ret[j++] = '\'';
ret[j++] = '\'';
}
}
else if (j < sizeof (ret))
{
ret[j++] = ch;
}
else
{
j++;
}
}
ret[sizeof (ret) - 1] = '\0';
return ret;
}
stock GetName(playerid)
{
new pnameid[24];
GetPlayerName(playerid,pnameid,sizeof(pnameid));
return pnameid;
}
stock PlayerIP(playerid)
{
new str[16];
GetPlayerIp(playerid, str, sizeof(str));
return str;
}
forward KickTimer(playerid);
public KickTimer(playerid)
{
Kick(playerid);
return 1;
}