14.12.2011, 23:49
Well, I added a vehicle system by Mauzen and edited it to my liking, compiled perfectly fine (although now I get a header message - thought nothing of it..) and now I'm getting a run time error 6.
Here's my script, if anyone can figure out what's wrong, that'd be really nice...
Here's my script, if anyone can figure out what's wrong, that'd be really nice...
pawn Код:
#include <a_samp>
#include <sscanf2>
#include <YSI\y_ini>
#include <zcmd>
#define MODE_NAME "New Equinox"
#define MODE_VERSION "0.1"
#define MODE_BUILD "0004"
new MODE_MOTD[528] = "Welcome to New Equinox Roleplay!~n~This server runs an RPG gamemode.~n~RPG stands for: ~y~R~w~ole ~y~P~w~laying ~y~G~w~ame.~n~~w~Thank you for choosing ~b~Equinox RPG!~n~~n~~w~Sincerely, ~b~The Equinox Team.";
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define COLOR_WAITING 0x4459BBFF
#define COLOR_CMD 0x51D52BFF
#define COLOR_SUCCESSFUL 0x1CE321FF
#define COLOR_ERROR 0xCF0610FF
#define COLOR_ANNOUNCE 0xD47E0FFF
#define PATH "/Accounts/%s.ini"
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
enum pInfo
{
Password,
Money,
Authorization,
Kills,
Deaths,
Points,
EventsWon,
UserTitle[128],
Skin,
LastLoggedIn[128],
Float:LastX,
Float:LastY,
Float:LastZ,
Float:LastRot,
LastInt,
LastVW
}
new UserInfo[MAX_PLAYERS][pInfo];
enum carDataEnum {
Model,
Float:SpawnX,
Float:SpawnY,
Float:SpawnZ,
Float:SpawnRot,
Color1,
Color2,
LicensePlate[32],
Owner[MAX_PLAYER_NAME]
}
new carData[MAX_VEHICLES][carDataEnum];
stock GetFreeVehicleSlot()
{
for(new i = 0; i < sizeof(validcar); i ++)
{
if(!validcar[i]) return i;
}
return -1;
}
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, licenseplate, ownername[MAX_PLAYER_NAME])
{
new carid = GetFreeVehicleSlot();
carData[carid][Model] = modelid;
carData[carid][SpawnX] = x;
carData[carid][SpawnY] = y;
carData[carid][SpawnZ] = z;
carData[carid][SpawnRot] = angle;
carData[carid][Color1] = color1;
carData[carid][Color2] = color2;
carData[carid][LicensePlate] = licenseplate;
carData[carid][Owner] = ownername;
validcar[carid] = true;
CreateVehicle(modelid, x, y, z, angle, color1, color2, 60000);
SetVehicleNumberPlate(modelid, carData[carid][LicensePlate]);
return carid;
}
stock SaveVehicle(vehicle, filename[36])
{
new File = INI_Open(filename);
INI_WriteInt(File, "Model", carData[vehicle][Model]);
INI_WriteFloat(File, "SpawnX", carData[vehicle][SpawnX]);
INI_WriteFloat(File, "SpawnY", carData[vehicle][SpawnY]);
INI_WriteFloat(File, "SpawnZ", carData[vehicle][SpawnZ]);
INI_WriteFloat(File, "SpawnRot", carData[vehicle][SpawnRot]);
INI_WriteInt(File, "Color1", carData[vehicle][Color1]);
INI_WriteInt(File, "Color2", carData[vehicle][Color2]);
INI_WriteString(File, "LicensePlate", carData[vehicle][LicensePlate]);
INI_WriteString(File, "Owner", carData[vehicle][Owner]);
INI_Close(filename);
}
stock SaveAllVehicles()
{
new saveindex = 0;
new fname[50];
for(new i = 0; i < MAX_VEHICLES; i ++)
{
if(validcar[i])
{
format(fname, sizeof(fname), "Vehicles/%d.ini", saveindex);
SaveVehicle(i, fname);
saveindex ++;
}
}
stock LoadVehicle(filename[36])
{
new
File = INI_Open(filename),
Model, Float:SpawnX,
Float:SpawnY, Float:SpawnZ,
Float:SpawnRot, Color1,
Color2, LicensePlate[32],
Owner[MAX_PLAYER_NAME];
INI_ReadInt(File, "Model", Model);
INI_ReadFloat(File, SpawnX);
INI_ReadFloat(File, SpawnY);
INI_ReadFloat(File, SpawnZ);
INI_ReadFloat(File, SpawnRot);
INI_ReadInt(File, "Color1", Color1);
INI_ReadInt(File, "Color2", Color2);
INI_ReadString(File, "LicensePlate", LicensePlate);
INI_ReadString(File, "Owner", Owner);
CreateVehicleEx(Model, SpawnX, SpawnY, SpawnZ, SpawnRot, Color1, Color2, 60000, Owner);
INI_Close(File);
}
stock LoadAllVehicles()
{
new fname[36];
new index = 0;
format(fname, sizeof(fname), "Vehicles/%d.ini", index);
while(fexist(fname))
{
LoadVehicle(fname);
index ++;
format(fname, sizeof(fname), "%d.ini", index);
}
}
new ClickedPlayer[MAX_PLAYERS] = -1, ChallengedUser[MAX_PLAYERS] = -1,
WouldLikeToDuel[MAX_PLAYERS] = -1, Dueling[MAX_PLAYERS] = -1,
TheirPoints[MAX_PLAYERS] = -1
;
new Text:BlackBox,
Text:Textdraw1, Text:Textdraw2,
Text:Textdraw3, Text:Textdraw4,
Text:Textdraw5, Text:PointsTD,
Text:WelcomeS2,
Text:WelcomeS3, Player_UpdateTD[MAX_PLAYERS]
;
new
FirstSpawn[MAX_PLAYERS] = -1
;
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password", UserInfo[playerid][Password]);
INI_Int("Cash", UserInfo[playerid][Money]);
INI_Int("Admin", UserInfo[playerid][Authorization]);
INI_Int("Kills", UserInfo[playerid][Kills]);
INI_Int("Deaths", UserInfo[playerid][Deaths]);
INI_Int("Points", UserInfo[playerid][Points]);
INI_Int("EventsWon", UserInfo[playerid][EventsWon]);
INI_Int("Skin", UserInfo[playerid][Skin]);
INI_String("UserTitle", UserInfo[playerid][UserTitle], 128);
INI_String("LastLoggedIn", UserInfo[playerid][LastLoggedIn], 128);
INI_Float("LastX", UserInfo[playerid][LastX]);
INI_Float("LastY", UserInfo[playerid][LastY]);
INI_Float("LastZ", UserInfo[playerid][LastZ]);
INI_Float("LastRot", UserInfo[playerid][LastRot]);
INI_Int("LastInt", UserInfo[playerid][LastInt]);
INI_Int("LastVW", UserInfo[playerid][LastVW]);
return 1;
}
main()
{
print(" ");
}
new bool:validcar[MAX_VEHICLES]
;
public OnGameModeInit()
{
new
g_Name[64];
format(g_Name, 64, "hostname %s v%s", MODE_NAME, MODE_VERSION);
SendRconCommand(g_Name);
format(g_Name, 64, "Build %s", MODE_BUILD);
SetGameModeText(g_Name);
BlackBox = TextDrawCreate(661.000000, 0.000000, "_");
TextDrawBackgroundColor(BlackBox, 255);
TextDrawFont(BlackBox, 1);
TextDrawLetterSize(BlackBox, 1000.000000, 1000.000000);
TextDrawColor(BlackBox, -1);
TextDrawSetOutline(BlackBox, 0);
TextDrawSetProportional(BlackBox, 1);
TextDrawSetShadow(BlackBox, 1);
TextDrawUseBox(BlackBox, 1);
TextDrawBoxColor(BlackBox, 255);
TextDrawTextSize(BlackBox, -50.000000, 30.000000);
Textdraw1 = TextDrawCreate(27.000000, 422.000000, "N");
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 2);
TextDrawLetterSize(Textdraw1, 0.500000, 2.000000);
TextDrawColor(Textdraw1, 65535);
TextDrawSetOutline(Textdraw1, 1);
TextDrawSetProportional(Textdraw1, 1);
Textdraw2 = TextDrawCreate(41.000000, 430.000000, "ew");
TextDrawBackgroundColor(Textdraw2, 255);
TextDrawFont(Textdraw2, 2);
TextDrawLetterSize(Textdraw2, 0.400000, 1.000000);
TextDrawColor(Textdraw2, -1);
TextDrawSetOutline(Textdraw2, 1);
TextDrawSetProportional(Textdraw2, 1);
Textdraw3 = TextDrawCreate(143.000000, 364.000000, "R~n~P");
TextDrawBackgroundColor(Textdraw3, 255);
TextDrawFont(Textdraw3, 1);
TextDrawLetterSize(Textdraw3, 0.600000, 2.000000);
TextDrawColor(Textdraw3, 65535);
TextDrawSetOutline(Textdraw3, 1);
TextDrawSetProportional(Textdraw3, 1);
Textdraw4 = TextDrawCreate(67.000000, 422.000000, "E");
TextDrawBackgroundColor(Textdraw4, 255);
TextDrawFont(Textdraw4, 2);
TextDrawLetterSize(Textdraw4, 0.400000, 2.000000);
TextDrawColor(Textdraw4, 65535);
TextDrawSetOutline(Textdraw4, 1);
TextDrawSetProportional(Textdraw4, 1);
Textdraw5 = TextDrawCreate(78.000000, 430.000000, "quinox");
TextDrawBackgroundColor(Textdraw5, 255);
TextDrawFont(Textdraw5, 2);
TextDrawLetterSize(Textdraw5, 0.400000, 1.000000);
TextDrawColor(Textdraw5, -1);
TextDrawSetOutline(Textdraw5, 1);
TextDrawSetProportional(Textdraw5, 1);
PointsTD = TextDrawCreate(509.000000, 10.000000, "[[ RP Points: 100 ]]");
TextDrawBackgroundColor(PointsTD, 255);
TextDrawFont(PointsTD, 3);
//TextDrawLetterSize(PointsTD, 0.290000, 0.799999);
TextDrawLetterSize(PointsTD, 0.290000, 0.899999);
TextDrawColor(PointsTD, -729935873);
TextDrawSetOutline(PointsTD, 1);
TextDrawSetProportional(PointsTD, 1);
WelcomeS2 = TextDrawCreate(75.000000, 115.000000, "WELCOME!");
TextDrawBackgroundColor(WelcomeS2, 255);
TextDrawFont(WelcomeS2, 3);
TextDrawLetterSize(WelcomeS2, 0.600000, 2.000000);
TextDrawColor(WelcomeS2, 16777215);
TextDrawSetOutline(WelcomeS2, 1);
TextDrawSetProportional(WelcomeS2, 1);
WelcomeS3 = TextDrawCreate(30.000000, 140.000000, MODE_MOTD);
TextDrawBackgroundColor(WelcomeS3, 255);
TextDrawFont(WelcomeS3, 1);
TextDrawLetterSize(WelcomeS3, 0.400000, 1.000000);
TextDrawColor(WelcomeS3, -1);
TextDrawSetOutline(WelcomeS3, 0);
TextDrawSetProportional(WelcomeS3, 1);
TextDrawSetShadow(WelcomeS3, 1);
LoadAllVehicles();
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
TogglePlayerSpectating(playerid, 1);
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
TextDrawShowForPlayer(playerid, BlackBox);
TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2);
TextDrawShowForPlayer(playerid, Textdraw4);
TextDrawShowForPlayer(playerid, Textdraw5);
TextDrawShowForPlayer(playerid, WelcomeS2);
TextDrawShowForPlayer(playerid, WelcomeS3);
ClearChat(playerid);
FirstSpawn[playerid] = 1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
new year, month, day;
new string[128];
new Float:Position[4];
getdate(year, month, day);
GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
GetPlayerFacingAngle(playerid, Position[3]);
INI_SetTag(File, "data");
INI_WriteInt(File, "Cash", UserInfo[playerid][Money]);
INI_WriteInt(File, "Admin", UserInfo[playerid][Authorization]);
INI_WriteInt(File, "Kills", UserInfo[playerid][Kills]);
INI_WriteInt(File, "Deaths", UserInfo[playerid][Deaths]);
INI_WriteInt(File, "Points", UserInfo[playerid][Points]);
INI_WriteInt(File, "EventsWon", UserInfo[playerid][EventsWon]);
INI_WriteString(File, "UserTitle", UserInfo[playerid][UserTitle]);
INI_WriteInt(File, "Skin", UserInfo[playerid][Skin]);
format(string, sizeof(string), "%d/%d/%d", month, day, year);
INI_WriteString(File, "LastLoggedIn", string);
INI_WriteFloat(File, "LastX", Position[0]);
INI_WriteFloat(File, "LastY", Position[1]);
INI_WriteFloat(File, "LastZ", Position[2]);
INI_WriteFloat(File, "LastRot", Position[3]);
INI_WriteInt(File, "LastInt", GetPlayerInterior(playerid));
INI_WriteInt(File, "LastVW", GetPlayerVirtualWorld(playerid));
INI_Close(File);
KillTimer(Player_UpdateTD[playerid]);
return 1;
}
public OnPlayerSpawn(playerid)
{
new string[128];
if(FirstSpawn[playerid] == 1) {
TextDrawShowForPlayer(playerid, PointsTD);
TheirPoints[playerid] = UserInfo[playerid][Points];
format(string, sizeof(string), "[[ RP Points: %d ]]", TheirPoints[playerid]);
TextDrawSetString(PointsTD, string);
SetPlayerVirtualWorld(playerid, UserInfo[playerid][LastVW]);
SetPlayerInterior(playerid, UserInfo[playerid][LastInt]);
TogglePlayerSpectating(playerid, false);
Player_UpdateTD[playerid] = SetTimerEx("UpdateTD", 1000, 1, "i", playerid); //Start updating the textdraws!
TextDrawShowForPlayer(playerid, Textdraw3);
TextDrawHideForPlayer(playerid, BlackBox);
TextDrawHideForPlayer(playerid, WelcomeS2);
TextDrawHideForPlayer(playerid, WelcomeS3);
//PlayAudioStreamForPlayer(playerid, "http://50.16.245.200/flv2ckby_live.mp3", 0, 0, 0, 50, 0);
FirstSpawn[playerid] = -1;
}
return 1;
}
forward UpdateTD(playerid);
public UpdateTD(playerid)
{
if(TheirPoints[playerid] != UserInfo[playerid][Points])
{
new string[128];
TheirPoints[playerid] = UserInfo[playerid][Points];
format(string, sizeof(string), "[[ RP Points: %d ]]", TheirPoints[playerid]);
TextDrawSetString(PointsTD, string);
}
return 1;
}
CMD:points(playerid, params[])
{
UserInfo[playerid][Points]++;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
UserInfo[killerid][Kills]++;
UserInfo[playerid][Deaths]++;
if(random(3) == 2) {
SendClientMessage(killerid, COLOR_SUCCESSFUL, "< You have randomly gained a point!");
UserInfo[killerid][Points]++;
}
if(Dueling[playerid] == 1 && Dueling[killerid] == 1) //Successfully detected that the player who died has been killed in a duel
{
new
annstring[128],
Winner[MAX_PLAYER_NAME], Loser[MAX_PLAYER_NAME]
;
GetPlayerName(killerid, Winner, 24);
GetPlayerName(playerid, Loser, 24);
format(annstring, sizeof(annstring), "[[ OOC: %s has beaten %s in a duel! ]]", Winner, Loser);
SendClientMessageToAll(COLOR_ANNOUNCE, annstring);
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
SetVehiclePos(vehicleid, carData[vehicleid][SpawnX], carData[vehicleid][SpawnY], carData[vehicleid][SpawnZ]);
SetVehicleZAngle(vehicleid, carData[vehicleid][SpawnRot]);
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new string[128];
new Float:health;
GetVehicleHealth(vehicleid, health);
format(string, sizeof(string), "Vehicle Health: %f", health);
SendClientMessage(playerid, -1, string);
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
if(strcmp(carData[GetPlayerVehicleID(playerid)][Owner] == "None")
{
}
}
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)
{
if(PRESSED(KEY_YES))
{
if(WouldLikeToDuel[playerid] != -1)
{
if(IsPlayerConnected(WouldLikeToDuel[playerid]))
{
if(Dueling[playerid] == 1)
return SendClientMessage(playerid, COLOR_ERROR, "< They are already dueling!");
SendClientMessage(playerid, COLOR_SUCCESSFUL, "> You have accepted the duel request.");
SendClientMessage(WouldLikeToDuel[playerid], COLOR_SUCCESSFUL, "> They have accepted your duel request.");
SetPlayerPos(WouldLikeToDuel[playerid], 0.0, 0.0, 0.0);
SetPlayerPos(playerid, 10.0, 10.0, 10.0);
ResetPlayerWeapons(playerid);
ResetPlayerWeapons(WouldLikeToDuel[playerid]);
SetPlayerVirtualWorld(WouldLikeToDuel[playerid], playerid+2);
SetPlayerVirtualWorld(playerid, playerid+2);
Dueling[playerid] = 1;
Dueling[WouldLikeToDuel[playerid]] = 1;
WouldLikeToDuel[playerid] = -1;
}
}
}
else if(PRESSED(KEY_NO))
{
if(WouldLikeToDuel[playerid] != -1)
{
if(IsPlayerConnected(WouldLikeToDuel[playerid]))
{
SendClientMessage(playerid, COLOR_SUCCESSFUL, "> You have declined the duel request.");
SendClientMessage(WouldLikeToDuel[playerid], COLOR_SUCCESSFUL, "> They have declined your duel request.");
WouldLikeToDuel[playerid] = -1;
}
}
}
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[])
{
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));
new skinid;
new year, month, day;
getdate(year, month, day);
skinid = random(299);
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, "Points", 0);
INI_WriteInt(File, "EventsWon",0);
INI_WriteInt(File, "Skin", skinid);
INI_WriteString(File, "UserTitle", "Newbie");
INI_WriteFloat(File, "LastX", 0.0000);
INI_WriteFloat(File, "LastY", 0.0000);
INI_WriteFloat(File, "LastZ", 0.0000);
INI_WriteFloat(File, "LastRot", 0.0000);
INI_WriteInt(File, "LastInt", 0);
INI_WriteInt(File, "LastVW", 0);
new string[128];
format(string, sizeof(string), "%d/%d/%d", month, day, year);
INI_WriteString(File, "LastLoggedIn", string);
UserInfo[playerid][Skin] = skinid;
INI_Close(File);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == UserInfo[playerid][Password])
{
new string[128];
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, UserInfo[playerid][Money]);
format(string, sizeof(string), "You last logged in on: %s!\nYou currently have %d points to spend!", UserInfo[playerid][LastLoggedIn], UserInfo[playerid][Points]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX, ""COL_WHITE"You have been logged in!", string, "Play", "");
new ranpoint = random(50);
if(ranpoint == 3) {
SendClientMessage(playerid, COLOR_SUCCESSFUL, "> You have randomly received a point for logging in!");
UserInfo[playerid][Points]++;
}
}
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;
}
}
case DIALOG_SUCCESS_2:
{
if(response)
{
new month, day, year;
new string[128];
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "data");
getdate(year, month, day);
format(string, sizeof(string), "%d/%d/%d", month, day, year);
INI_WriteString(File, "LastLoggedIn", string);
TogglePlayerSpectating(playerid, 0);
SetSpawnInfo(playerid, 0, UserInfo[playerid][Skin], UserInfo[playerid][LastX], UserInfo[playerid][LastY], UserInfo[playerid][LastZ], UserInfo[playerid][LastRot], 24, 999999, 31, 99999, 34, 99999);
SpawnPlayer(playerid);
GameTextForPlayer(playerid, "~w~Session ~n~~g~continued", 3000, 1);
INI_Close(File);
}
}
case 100:
{
switch(listitem)
{
case 0:
{
if(response)
{
new string1[45], string2[256], p_Name[24];
GetPlayerName(ClickedPlayer[playerid], p_Name, 24);
format(string1, sizeof(string1), "{095DBD}[~] {FFFFFF}Player %s: Statistics", p_Name);
new UserLevel[60];
if(UserInfo[ClickedPlayer[playerid]][Authorization] == 0)
{
UserLevel = "Normal User";
}
else if(UserInfo[ClickedPlayer[playerid]][Authorization] == 1) {
UserLevel = "Moderator";
}
else if(UserInfo[ClickedPlayer[playerid]][Authorization] == 2) {
UserLevel = "Junior Administrator";
}
else if(UserInfo[ClickedPlayer[playerid]][Authorization] == 3) {
UserLevel = "Game Administrator";
}
else if(UserInfo[ClickedPlayer[playerid]][Authorization] == 4) {
UserLevel = "Senior Administrator";
}
else if(UserInfo[ClickedPlayer[playerid]][Authorization] == 5) {
UserLevel = "Head Administrator";
}
format(string2, sizeof(string2), "{095DBD}User Level: \t{FFFFFF}%s\n{095DBD}Kills: \t\t{FFFFFF}%d\n{095DBD}Deaths: \t{FFFFFF}%d\n{095DBD}Points: \t{FFFFFF}%d\n{095DBD}Events Won: \t{FFFFFF}%d", UserLevel, UserInfo[ClickedPlayer[playerid]][Kills], UserInfo[ClickedPlayer[playerid]][Deaths], UserInfo[ClickedPlayer[playerid]][Points], UserInfo[ClickedPlayer[playerid]][EventsWon]);
ShowPlayerDialog(playerid, 100+1, DIALOG_STYLE_MSGBOX, string1, string2, "Back", "");
}
else {
ClickedPlayer[playerid] = -1;
return 1;
}
}
case 1: //challenge
{
/*if(ClickedPlayer[playerid] == playerid)
{
ClickedPlayer[playerid] = -1;
return 0;
}
else
{*/
ChallengedUser[playerid] = ClickedPlayer[playerid];
new string[128], p_Name[24], p_Name2[24];
GetPlayerName(playerid, p_Name, 24);
GetPlayerName(ClickedPlayer[playerid], p_Name2, 24);
format(string, sizeof(string), "> %s would like to challenge you to a duel, Press Y or N to accept/deny this request.", p_Name);
SendClientMessage(ClickedPlayer[playerid], COLOR_SUCCESSFUL, string);
format(string, sizeof(string), "> Duel request sent to %s.", p_Name2);
SendClientMessage(playerid, COLOR_SUCCESSFUL, string);
WouldLikeToDuel[ChallengedUser[playerid]] = playerid;
return 1;
//}
}
}
return 1;
}
case 101:
{
if(response)
{
new string[128];
new p_Name[MAX_PLAYER_NAME];
GetPlayerName(ClickedPlayer[playerid], p_Name, sizeof(p_Name));
format(string, sizeof(string), "{095DBD}[~] {FFFFFF}Player %s", p_Name);
ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, string, "Statistics\nChallenge\nBlock user", "Select", "Close");
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
new string[128];
new p_Name[MAX_PLAYER_NAME];
GetPlayerName(clickedplayerid, p_Name, sizeof(p_Name));
format(string, sizeof(string), "{095DBD}[~] {FFFFFF}Player %s", p_Name);
ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, string, "Statistics\nChallenge\nBlock user", "Select", "Close");
ClickedPlayer[playerid] = clickedplayerid;
return 1;
}
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat) {
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 ClearChat(playerid) {
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, " ");
return 1;
}
stock GetPlayerSpeed(playerid) {
new vID = GetPlayerVehicleID(playerid);
new Float:Velocity[4];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(vID,Velocity[0],Velocity[1],Velocity[2]);
else GetPlayerVelocity(playerid,Velocity[0],Velocity[1],Velocity[2]);
Velocity[3] = floatsqroot(floatpower(floatabs(Velocity[0]), 2.0) + floatpower(floatabs(Velocity[1]), 2.0) + floatpower(floatabs(Velocity[2]), 2.0)) * 179.28625;
return floatround(Velocity[3]);
}
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;
}
stock IsAuthorized(playerid, requiredlevel)
{
if(UserInfo[playerid][Authorization] >= requiredlevel)
return 1;
else
return 0;
}
CMD:spawnvehicle(playerid, params[])
{
new
VehicleModel,
VehicleColor1,
VehicleColor2,
string[128],
Vehicle,
Float:Position[4];
if(!IsAuthorized(playerid, 3))
return SendClientMessage(playerid, COLOR_ERROR, "< Invalid permissions!");
if(sscanf(params, "iii", VehicleModel, VehicleColor1, VehicleColor2))
return SendClientMessage(playerid, COLOR_CMD, "Correct Usage: /SpawnVehicle [Vehicle ID] [Color1] [Color2] - (SHORTCUT: /sv - Same params)");
GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
GetPlayerFacingAngle(playerid, Position[3]);
//Vehicle = CreateVehicle(VehicleModel, Position[0], Position[1], Position[2], Position[3], VehicleColor1, VehicleColor2, 60000);
LinkVehicleToInterior(Vehicle, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(Vehicle, GetPlayerVirtualWorld(playerid));
Vehicle = CreateVehicleEx(VehicleModel, Position[0], Position[1], Position[2], Position[3], VehicleColor1, VehicleColor2, "SA0000", "None");
PutPlayerInVehicle(playerid, Vehicle, 0); //0 = Driver
format(string, sizeof(string), "< Vehicle spawned! (Model: %d, Vehicle ID: %d)", VehicleModel, GetPlayerVehicleID(playerid));
SendClientMessage(playerid, COLOR_SUCCESSFUL, string);
return 1;
}
CMD:sv(playerid, params[])
{
return cmd_spawnvehicle(playerid, params);
}
CMD:timeofday(playerid, params[])
{
new
TimeofDay,
string[128],
p_Username[MAX_PLAYER_NAME];
if(!IsAuthorized(playerid, 1))
return SendClientMessage(playerid, COLOR_ERROR, "< Invalid permissions!");
if(sscanf(params, "i", TimeofDay))
return SendClientMessage(playerid, COLOR_CMD, "Correct Usage: /TimeofDay [0-24] - (SHORTCUT: /tod - Same params)");
SetWorldTime(TimeofDay);
GetPlayerName(playerid, p_Username, sizeof(p_Username));
format(string, sizeof(string), "< Administrator %s changed the Server Time to %d:00!", p_Username, TimeofDay);
SendClientMessageToAll(COLOR_SUCCESSFUL, string);
return 1;
}
CMD:tod(playerid, params[])
{
return cmd_timeofday(playerid, params);
}
CMD:authorize(playerid, params[])
{
new
Player,
AuthLevel,
Auth;
if(!IsAuthorized(playerid, 4))
return SendClientMessage(playerid, COLOR_ERROR, "< Invalid permissions!");
if(sscanf(params, "ui", Player, AuthLevel))
return SendClientMessage(playerid, COLOR_CMD, "Correct Usage: /Authorize [Player ID] [User Level] - (SHORTCUT: /auth - Same params)");
Auth = UserInfo[Player][Authorization];
UserInfo[Player][Authorization] = AuthLevel;
SendClientMessage(Player, COLOR_SUCCESSFUL, "< Your authorization level has been edited.");
SendClientMessage(playerid, COLOR_SUCCESSFUL, "< Action complete.");
new p_Name1[24], p_Name2[24];
GetPlayerName(playerid, p_Name1, 24);
GetPlayerName(Player, p_Name2, 24);
printf("[!] %s has edited %s's file | Var: Authorization | Change: %d -> %d", p_Name1, p_Name2, Auth, AuthLevel);
return 1;
}
CMD:auth(playerid, params[])
{
return cmd_authorize(playerid, params);
}
CMD:logout(playerid, params[])
{
new
Float:Pos[4];
new INI:File = INI_Open(UserPath(playerid));
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
UserInfo[playerid][LastX] = Pos[0];
UserInfo[playerid][LastZ] = Pos[1];
UserInfo[playerid][LastY] = Pos[2];
UserInfo[playerid][LastRot] = Pos[3];
INI_SetTag(File, "data");
INI_WriteFloat(File, "LastX", Pos[0]);
INI_WriteFloat(File, "LastY", Pos[1]);
INI_WriteFloat(File, "LastZ", Pos[2]);
INI_WriteFloat(File, "LastRot", Pos[3]);
INI_WriteInt(File, "LastInt", GetPlayerInterior(playerid));
INI_WriteInt(File, "LastVW", GetPlayerVirtualWorld(playerid));
INI_Close(File);
//TogglePlayerSpectating(playerid, true);
OnPlayerConnect(playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_GREEN"You have been logged out.\n"COL_WHITE"Type your password below to login.","Login","Quit");
return 1;
}
CMD:addcomp(playerid, params[])
{
new
ComponentID;
if(sscanf(params, "i", ComponentID))
return SendClientMessage(playerid, COLOR_CMD, "Correct Usage: /AddComp [Component ID] - (SHORTCUT: /ac - Same params)");
if(IsAuthorized(playerid, 3))
{
AddVehicleComponent(GetPlayerVehicleID(playerid), ComponentID);
}
return 1;
}
CMD:ac(playerid, params[])
{
return cmd_addcomp(playerid, params);
}
CMD:spawnmoney(playerid, params[])
{
new
Amount,
User;
if(!IsAuthorized(playerid, 4))
return SendClientMessage(playerid, COLOR_ERROR, "< Invalid permissions!");
UserInfo[User][Money] += Amount;
return 1;
}