Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <ZCMD>
- #include <foreach>
- #include <sscanf2>
- #include <YSI\y_ini>
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLUE 0x0000BBAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_LIME 0x10F441AA
- #define COLOR_MAGENTA 0xFF00FFFF
- #define COLOR_NAVY 0x000080AA
- #define COLOR_AQUA 0xF0F8FFAA
- #define COLOR_CRIMSON 0xDC143CAA
- #define COLOR_FLBLUE 0x6495EDAA
- #define COLOR_BISQUE 0xFFE4C4AA
- #define COLOR_BLACK 0x000000AA
- #define COLOR_CHARTREUSE 0x7FFF00AA
- #define COLOR_BROWN 0XA52A2AAA
- #define COLOR_CORAL 0xFF7F50AA
- #define COLOR_GOLD 0xB8860BAA
- #define COLOR_GREENYELLOW 0xADFF2FAA
- #define COLOR_INDIGO 0x4B00B0AA
- #define COLOR_IVORY 0xFFFF82AA
- #define COLOR_LAWNGREEN 0x7CFC00AA
- #define COLOR_SEAGREEN 0x20B2AAAA
- #define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
- #define COLOR_MIDNIGHTBLUE 0X191970AA
- #define COLOR_MAROON 0x800000AA
- #define COLOR_OLIVE 0x808000AA
- #define COLOR_ORANGERED 0xFF4500AA
- #define COLOR_PINK 0xFFC0CBAA // - Light light pink
- #define COLOR_SPRINGGREEN 0x00FF7FAA
- #define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
- #define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
- #define COLOR_MEDIUMAQUA 0x83BFBFAA
- #define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) //Detecting keys
- #define TEAM_POLICE 0
- #define TEAM_TRUCKER 1
- #define dregister 2011 //Defining register dialog so it won't mixed up with the other dialogs
- #define dlogin 2012 //Defining login dialog so it won't mixed up with the other dialogs
- #define UserPath "Users/%s.ini" /*Will define user's account path. In this case, we will save it in Scriptfiles/Users. So create a file inside of your Scriptfiles folder called Users*/
- native WP_Hash(buffer[],len,const str[]); // Whirlpool native, add it at the top of your script under includes
- //We will create an enum to store player's data.
- enum PlayerInfo
- {
- Pass[129], //User's password
- Adminlevel, //User's admin level
- VIPlevel, //User's vip level
- Money, //User's money
- Scores, //User's scores
- Kills, //User's kills
- Deaths //User's deaths
- }
- new pInfo[MAX_PLAYERS][PlayerInfo]; /*This will create a new variable so we can later use it to saving/loading user's info.*/
- stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
- {
- new str[128],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- format(str,sizeof(str),UserPath,name);
- return str;
- }
- forward loadaccount_user(playerid, name[], value[]); //forwarding a new function to load user's data
- //Now we will use our own function that we have created above
- public loadaccount_user(playerid, name[], value[])
- {
- INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
- ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
- INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
- INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
- INI_Int("Money",pInfo[playerid][Money]); //As explained above
- INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
- INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
- INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
- return 1;
- }
- new Engine[MAX_VEHICLES], Lights[MAX_VEHICLES];
- new Text:td_fuel[MAX_PLAYERS];
- new Text:td_vhealth[MAX_PLAYERS];
- new Text:td_box[MAX_PLAYERS];
- forward timer_refuel(playerid);
- forward timer_fuel_lower();
- new isrefuelling[MAX_PLAYERS] = 0;
- new fuel[MAX_VEHICLES];
- new Float:max_vhealth[MAX_VEHICLES];
- new iMissionText[512][MAX_PLAYERS], Float:unx[MAX_PLAYERS], Float:uny[MAX_PLAYERS], Float:unz[MAX_PLAYERS], iPay[MAX_PLAYERS], MissionStatus[MAX_PLAYERS];
- new gTeam[MAX_PLAYERS];
- new Float:svx[MAX_PLAYERS]; // Holds Velocity X
- new Float:svy[MAX_PLAYERS]; // Holds Velocity Y
- new Float:svz[MAX_PLAYERS]; // Holds Velocity Z
- new Float:sp1[MAX_PLAYERS]; // This Is What Our Forumula Outputs
- new sp2[MAX_PLAYERS]; // This Is The Output When The Forumula's Ouput Is Round
- new sp3[MAX_PLAYERS][256]; // This Is The Text That Is Displayed To The User
- new Text:sdisplay[MAX_PLAYERS]; // This Holds The Textdraw's ID
- new stimer[MAX_PLAYERS]; // This Holds The Timer's ID (Used To Refresh Speed)
- forward speedometer(playerid); // This Forwards The Timer To Our Function
- stock ProxDetector(Float:radi, playerid, string[],color)
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- foreach(Player,i)
- {
- if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
- {
- SendClientMessage(i,color,string);
- }
- }
- }
- stock GetName(playerid)
- {
- new getthename[MAX_PLAYER_NAME];
- GetPlayerName(playerid,getthename,sizeof(getthename));
- return getthename;
- }
- forward MSG();
- new Text:ServerMSG;
- new RMessages[][] =
- {
- "~y~Random News: ~w~Hei på deg",
- "~y~Random News: ~w~Gulost",
- "~y~Random News: ~w~dont worry, be happy",
- "~y~Random News: ~w~Karl :)",
- "~y~Random News: ~w~Hade"
- };
- new
- afk[ MAX_PLAYERS char ]
- ;
- enum MisLocationsEnum
- {
- ID,
- LoadName[128],
- Float:LoadX,
- Float:LoadY,
- Float:LoadZ,
- Float:UnloadX,
- Float:UnloadY,
- Float:UnloadZ,
- Pay
- }
- new MisLocations[][MisLocationsEnum] =
- {
- {0, "Beer from Red County Brewery to Bone County Diner",-24.4073,-281.8898,5.9985,-305.4319,1315.6797,54.6189, 5980},
- {1, "Fuel from LV Oil Refinery to LV Dirtring",266.8981,1416.5417,10.2001,1097.5164,1741.7422,10.5474, 5700},
- {2, "Vehicle Parts from SF Airport ATC to Wang Cars",-1268.8223,13.6925,14.8682,-1986.3477,253.9728,35.8985, 3000},
- {3, "Fuel from SF Oil Refinery to RS Haul",-1016.3634,-688.2434,32.7284,-55.3397,-1138.2479,0.8052, 18770}//The last one in the array doesn't have a comma at the end.
- };
- main()
- {
- print("\n----------------------------------");
- print(" Min super gamemode");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- SetGameModeText("Min Super Gamemode");
- UsePlayerPedAnims();
- ManualVehicleEngineAndLights();//Instead of vehicle engines and lights automatic, they are now manual.
- AddPlayerClass(72, 2134.8254,-2147.6038,13.7015,212.6795, 0,0,0,0,0,0);
- AddPlayerClass(282, 2502.7112,2772.9893,10.8203,272.5301, 0,0,0,0,0,0);
- for(new i=0;i<MAX_VEHICLES;i++) {
- GetVehicleHealth(i,max_vhealth[i]); //getting max health
- fuel[i] = 250 + random(150); //setting fuel for vehicles
- }
- for(new i=0;i<MAX_PLAYERS;i++) { //setting up all textdraws
- ServerMSG = TextDrawCreate(7.000000, 427.000000, "You don't need to add any text here");
- TextDrawBackgroundColor(ServerMSG, 255);
- TextDrawFont(ServerMSG, 1);
- TextDrawLetterSize(ServerMSG, 0.379999, 1.499999);
- TextDrawColor(ServerMSG, -1);
- TextDrawSetOutline(ServerMSG, 1);
- TextDrawSetProportional(ServerMSG, 1);
- td_fuel[i] = TextDrawCreate(476,355,"Fuel:");
- td_vhealth[i] = TextDrawCreate(478,376,"Health:");
- sdisplay[i] = TextDrawCreate(478,397,"Speed:"); // This Creates Our Textdraw And Stores The Id In The Varible In Front
- td_box[i] = TextDrawCreate(478.000000,328.000000,"Vehicle Stats: ~n~~n~~n~~n~");
- TextDrawUseBox(td_box[i],1);
- TextDrawBoxColor(td_box[i],0x00000066);
- TextDrawTextSize(td_box[i],626.000000,21.000000);
- TextDrawAlignment(td_fuel[i],0);
- TextDrawAlignment(td_vhealth[i],0);
- TextDrawAlignment(sdisplay[i],0);
- TextDrawAlignment(td_box[i],0);
- TextDrawBackgroundColor(td_fuel[i],0x000000ff);
- TextDrawBackgroundColor(td_vhealth[i],0x000000ff);
- TextDrawBackgroundColor(sdisplay[i],0x000000ff);
- TextDrawBackgroundColor(td_box[i],0x000000cc);
- TextDrawFont(td_fuel[i],1);
- TextDrawLetterSize(td_fuel[i],0.699999,2.699999);
- TextDrawFont(td_vhealth[i],1);
- TextDrawLetterSize(td_vhealth[i],0.699999,2.699999);
- TextDrawFont(sdisplay[i],1);
- TextDrawLetterSize(sdisplay[i],0.699999,2.699999);
- TextDrawFont(td_box[i],0);
- TextDrawLetterSize(td_box[i],0.699999,2.899999);
- TextDrawColor(td_fuel[i],0xffffffff);
- TextDrawColor(td_vhealth[i],0xffffffff);
- TextDrawColor(sdisplay[i],0xffffffff);
- TextDrawColor(td_box[i],0xffffffff);
- TextDrawSetOutline(td_fuel[i],1);
- TextDrawSetOutline(td_vhealth[i],1);
- TextDrawSetOutline(sdisplay[i],1);
- TextDrawSetOutline(td_box[i],1);
- TextDrawSetProportional(td_fuel[i],1);
- TextDrawSetProportional(td_vhealth[i],1);
- TextDrawSetProportional(sdisplay[i],1);
- TextDrawSetProportional(td_box[i],1);
- TextDrawSetShadow(td_fuel[i],1);
- TextDrawSetShadow(td_vhealth[i],1);
- TextDrawSetShadow(sdisplay[i],1);
- TextDrawSetShadow(td_box[i],10);
- }
- SetTimer("timer_update",100,true);
- SetTimer("timer_fuel_lower",8200,true);
- SetTimer("RandomMessage",8000,1); // 8000 is for 8 seconds, if you want 50 seconds use 50000
- CreateVehicle(515,2503.0000000,2760.1999500,12.0000000,270.0000000,208,13,15); //Roadtrain
- return 1;
- }
- public MSG()
- {
- TextDrawSetString(ServerMSG, RMessages[random(sizeof(RMessages))]);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- SetPlayerTeamFromClass(playerid, classid);
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerTeamFromClass(playerid, classid);
- SetPlayerPos(playerid, 2527.1042,-1664.5869,15.1666);
- SetPlayerFacingAngle(playerid,180);
- SetPlayerCameraPos(playerid,2526.9868,-1666.8330,15.1683);
- SetPlayerCameraLookAt(playerid,2527.1042,-1664.5869,15.1666);
- return 1;
- }
- /*OnPlayerConnect will be called when players is connected to your server. So now we will need to show a register or login dialog*/
- public OnPlayerConnect(playerid)
- {
- new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
- GetPlayerName(playerid,name,sizeof(name)); //Get player's name
- if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
- {// then
- INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
- ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
- }
- else //If the connected user is not registered,
- {//then we will 'force' him to register :)
- ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
- return 1;
- }
- return 1;
- }
- public speedometer(playerid) {
- GetVehicleVelocity(GetPlayerVehicleID(playerid), svx[playerid], svy[playerid], svz[playerid]); // This Saves Our Velocitys To Our Varibles
- sp1[playerid] = floatsqroot(((svx[playerid]*svx[playerid])+(svy[playerid]*svy[playerid]))+(svz[playerid]*svz[playerid]))*136.666667; // This Is Our Forumula ( I Don't Know How It Works )
- sp2[playerid] = floatround(sp1[playerid],floatround_round); // This Rounds Our Output To The Nearest Whole Number
- format(sp3[playerid],256,"Speed: %i KM/H", sp2[playerid]); // This Format Our Text Into What We See
- TextDrawSetString(sdisplay[playerid], sp3[playerid]); // This Changes The Value Of Our Textdraw To What We Formatted
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- //Same as OnDialogResponse, we will save their stats inside of their user's account
- new INI:file = INI_Open(Path(playerid)); //will open their file
- INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
- INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
- INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
- INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
- INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
- INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
- INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
- INI_Close(file);//Now after we've done saving their data, we now need to close the file
- return 1;
- }
- CMD:pm(playerid, params[])
- {
- new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
- if(sscanf(params, "us", id, str2))
- {
- SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
- return 1;
- }
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "The player is not connected");
- if(playerid == id) return SendClientMessage(playerid, COLOR_RED, "You can't pm yourself!");
- {
- GetPlayerName(playerid, Name1, sizeof(Name1));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
- SendClientMessage(playerid, COLOR_LIME, str);
- format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
- SendClientMessage(id, COLOR_LIME, str);
- }
- return 1;
- }
- CMD:me(playerid, params[])
- {
- new string[128], action[100];
- if(sscanf(params, "s[100]", action))
- {
- SendClientMessage(playerid, -1, "USAGE: /me [action]");
- return 1;
- }
- else
- {
- format(string, sizeof(string), "* %s %s", GetName(playerid));
- ProxDetector(30, playerid, string, COLOR_WHITE);
- }
- return 1;
- }
- CMD:do(playerid, params[])
- {
- new string[128], action[100];
- if(sscanf(params, "s[100]", action))
- {
- SendClientMessage(playerid, -1, "USAGE: /do [action]");
- return 1;
- }
- else
- {
- format(string, sizeof(string), "* %s (( %s ))", action, GetName(playerid));
- ProxDetector(30, playerid, string, COLOR_WHITE);
- }
- return 1;
- }
- CMD:shout(playerid, params[])
- {
- new string[128], shout[100];
- if(sscanf(params, "s[100]", shout))
- {
- SendClientMessage(playerid, -1, "USAGE: /(s)hout [message]");
- return 1;
- }
- else
- {
- format(string, sizeof(string), "%s shouts: %s!",GetName(playerid),shout);
- ProxDetector(50.0, playerid, string, -1);
- }
- return 1;
- }
- CMD:b(playerid, params[])
- {
- new string[128], text[100];
- if(sscanf(params, "s[100]", text)) return SendClientMessage(playerid, -1, "USAGE: /b [TEXT]");
- format(string, sizeof(string), "(( %s says: %s ))", GetName(playerid), text);
- ProxDetector(30.0, playerid, string, COLOR_WHITE);
- return 1;
- }
- CMD:afk(playerid, params[]) {
- new name[MAX_PLAYER_NAME], string[128];
- GetPlayerName(playerid, name, sizeof(name));
- if( afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - You're already afk!");
- else
- {
- afk{ playerid } = true;
- SetPlayerHealth(playerid, 99999);
- SetPlayerArmour(playerid, 99999);
- TogglePlayerControllable(playerid, 0);
- format(string, sizeof(string), "[AFK] - %s is now afk!", name);
- SendClientMessageToAll(COLOR_ORANGE, string);
- SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - When you come back, use /back!");
- }
- return 1;
- }
- CMD:back(playerid, params[]) {
- if( !afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[BACK] - You aren't afk!");
- else
- {
- new name[MAX_PLAYER_NAME], string[128];
- GetPlayerName(playerid, name, sizeof(name));
- SetPlayerHealth(playerid, 99);
- SetPlayerArmour(playerid, 99);
- TogglePlayerControllable(playerid, 1);
- format(string, sizeof(string), "[BACK] - %s is now back!", name);
- SendClientMessageToAll(COLOR_GREEN, string);
- SendClientMessage(playerid, COLOR_GREEN, "[BACK] - Welcome back!");
- afk{ playerid } = false;
- }
- return 1;
- }
- CMD:smoke(playerid, params[])
- {
- SetPlayerSpecialAction(playerid,SPECIAL_ACTION_SMOKE_CIGGY);
- return 1;
- }
- CMD:rules(playerid, params[])
- {
- ShowPlayerDialog(playerid, 999, DIALOG_STYLE_MSGBOX, "My Server Rules", "No Hacking Or Advertising\nNo Cbugging or Stop Animation\nNo Insulting other Player\nNo Car Ramming or HeliKilling\nNo Using 3rd Party tools that give player more advantage\nPlease Follow these rules", "Ok","");
- return 1;
- }
- CMD:repair(playerid, params[])
- {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a vehicle!");
- if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You are not in the driver seat!");
- RepairVehicle(GetPlayerVehicleID(playerid));
- SendClientMessage(playerid, COLOR_GREEN, "Your vehicle has been sucessfully repaired.");
- PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
- return 1;
- }
- CMD:flip(playerid, params[])
- {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be in a vehicle.");
- {
- new vehicle;
- new Float:zangle;
- vehicle = GetPlayerVehicleID(playerid);
- GetVehicleZAngle(vehicle,zangle);
- SetVehicleZAngle(vehicle,zangle);
- SendClientMessage(playerid,COLOR_GREEN,"Vehicle succesfully flipped.");
- }
- return 1;
- }
- CMD:work(playerid, params[])
- {
- if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return T_NewJob(playerid);
- return 1;
- }
- CMD:stopwork(playerid, params[])
- {
- if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return StopWork(playerid);
- return 1;
- }
- stock T_NewJob(playerid)
- {
- new vID = GetPlayerVehicleID(playerid); //gets called on the next line
- if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)//this checks wether the player is in a Roadtrain, Tanker or Linerunner
- {
- if(IsTrailerAttachedToVehicle(vID))// This checks wether the player has a trailer attached
- {
- MissionStatus[playerid] = 1;// this sets the players mission status as 1 - So they are on a mission.
- new MisRand = random(sizeof(MisLocations));// this is the line that will call a random mission.
- new LoadText[128], Float:x, Float:y, Float:z;// these are where we will store each co-ord and the text for the mission
- x = MisLocations[MisRand][LoadX];//this sets one of the above
- y = MisLocations[MisRand][LoadY];//this sets one of the above
- z = MisLocations[MisRand][LoadZ];//this sets one of the above
- unx[playerid] = MisLocations[MisRand][UnloadX];//these set what we made in step 10.
- uny[playerid] = MisLocations[MisRand][UnloadY];//these set what we made in step 10.
- unz[playerid] = MisLocations[MisRand][UnloadZ];//these set what we made in step 10.
- iPay[playerid] = MisLocations[MisRand][Pay];//these set what we made in step 10.
- SetPlayerCheckpoint(playerid, x, y, z, 7);//This creates the checkpoint that the player will enter.
- format(LoadText, 128, "%s",MisLocations[MisRand][LoadName]);// this is formatting the text the player will see in the console
- SendClientMessage(playerid, COLOR_GREEN, "Mission:");//sends message in console
- SendClientMessage(playerid, COLOR_GREEN, "_____________________");//sends message in console
- SendClientMessage(playerid, COLOR_GREEN, "");//sends message in console
- SendClientMessage(playerid, 0xFFFFFFFF, LoadText);//sends the text we formatted earlier in console
- SendClientMessage(playerid, COLOR_GREEN, "_____________________");//sends message in console
- }
- else//if the player doesnt have a trailer attached
- {
- SendClientMessage(playerid, COLOR_RED, "You need a trailer!");//sends message in console
- }
- }
- else//if the player isnt in a truck
- {
- SendClientMessage(playerid, COLOR_RED, "You must be in a Truck to perform this!");//sends message in console
- }
- return 1;
- }
- stock StopWork(playerid)
- {
- DisablePlayerCheckpoint(playerid);
- SendClientMessage(playerid, COLOR_RED, "You chose to cancel the mission and got fined $3000");
- GivePlayerMoney(playerid, -3000);
- MissionStatus[playerid] = 0;
- return 1;
- }
- CMD:unlock(playerid, params[])
- {
- new engine, lights, alarm, doors, bonnet, boot, objective;
- new vehicleid = GetPlayerVehicleID(playerid);//defining vehicleid is = to GetPlayerVehicleID.
- if(IsPlayerInAnyVehicle(playerid))//Thsi will check that is a player In a vehcile or not.
- {
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//will check that what is the state of the vehicle lock.
- if(doors == 1)//will check if the doors are already loocked it not.
- {
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,false,bonnet,boot,objective);//same as the engine one.
- GameTextForPlayer(playerid,"Vehicle unlocked!",2000,6);//for a text to appar on the screen for only 2 seconds.
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid,-1,"Error: You are not in a vehicle!");//the error message.
- }
- return 1;
- }
- CMD:lock(playerid, params[])
- {
- new engine, lights, alarm, doors, bonnet, boot, objective;
- new vehicleid = GetPlayerVehicleID(playerid);//defining vehicleid is = to GetPlayerVehicleID.
- if(IsPlayerInAnyVehicle(playerid))//Thsi will check that is a player In a vehcile or not.
- {
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//will check that what is the state of the vehicle lock.
- if(doors == 0)//will check if the doors are already loocked it not.
- {
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,true,bonnet,boot,objective);//same as the engine one.
- GameTextForPlayer(playerid,"Vehicle locked!",2000,6);//for a text to appar on the screen for only 2 seconds.
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid,-1,"Error: You are not in a vehicle!");//the error message.
- }
- return 1;
- }
- //------------------------------------------------------------------END OF COMMANDS-----------------------------------------------------------//
- //--------------------------------------------------------------------------------------------------------------------------------------------//
- SetPlayerToTeamColor(playerid);
- public OnPlayerSpawn(playerid)
- {
- TextDrawShowForPlayer(playerid, ServerMSG);
- SetPlayerToTeamColor(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pInfo[killerid][Kills]++;//Will give 1 kill to killer and it will be saved inside of his/her account
- pInfo[playerid][Deaths]++;//Will give 1 death each time they die and it will be saved inside of his/her account
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- Engine[vehicleid] = 0;
- Lights[vehicleid] = 0;
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText( playerid, text[] )
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- KillTimer(stimer[playerid]); // This Stops Our Timer For When You Get Out Of Your Vehicle Your Speed Doesn't Keep Going
- TextDrawSetString(sdisplay[playerid], " "); // This Sets Our Textdraw To Blank And Freezes Because We Stop The Timer ^
- if(newstate == 2) stimer[playerid] = SetTimerEx("speedometer", 255, true, "i", playerid); // This Starts The Timer When The Player Changes His/Her State To Being The Driver
- else if(newstate == 3) stimer[playerid] = SetTimerEx("speedometer", 250, true, "i", playerid); // This Start The Timer When The Player Changes His/Her Start To Being The Passenger
- if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
- {
- TextDrawSetString(td_fuel[playerid],"Fuel:");
- TextDrawSetString(td_vhealth[playerid],"Health:");
- TextDrawSetString(sdisplay[playerid],"Speed:");
- TextDrawShowForPlayer(playerid,td_fuel[playerid]);
- TextDrawShowForPlayer(playerid,sdisplay[playerid]);
- TextDrawShowForPlayer(playerid,td_vhealth[playerid]);
- TextDrawShowForPlayer(playerid,td_box[playerid]);
- } else {
- TextDrawHideForPlayer(playerid,td_fuel[playerid]);
- TextDrawHideForPlayer(playerid,sdisplay[playerid]);
- TextDrawHideForPlayer(playerid,td_vhealth[playerid]);
- TextDrawHideForPlayer(playerid,td_box[playerid]);
- }
- return 1;
- }
- CMD:refuel(playerid, params[])
- {
- if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"You are not in an vehicle!"); //if a player isnt in a vehicle, it stops here
- if (isrefuelling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already refuelling!"); //if a player is already refuelling, it stops here
- if (GetPlayerMoney(playerid) - 80 <0) return SendClientMessage(playerid,0xFFC800FF,"You dont have enough money!"); //if a player doesnt have $80 anymore, it stops here
- GivePlayerMoney(playerid,-80); //Sets the player's cash -$80
- SetCameraBehindPlayer(playerid); //Sets the camera behind the player (looks better because the player will be frozen for a few secs)
- TogglePlayerControllable(playerid,0); //freezes the player so he cant drive and refuel at the same time
- isrefuelling[playerid] = 1; //setting isrefuelling to 1 so the player cant spam /refuel
- TextDrawSetString(td_fuel[playerid],"Refuelling..."); //changing textdraw to /refuel
- SetTimerEx("timer_refuel",4500,false,"i",playerid); //setting refueltimer
- return 1;
- }
- public timer_fuel_lower()
- {
- for(new i=0;i<MAX_PLAYERS;i++) { //loop for all players
- if (isrefuelling[i]) continue; //stop when a player is already refuelling
- new vid = GetPlayerVehicleID(i); //getting vehicle ID
- new engine,lights,alarm,doors,bonnet,boot,objective;//The vehicle params
- GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);//Getting the vehicle params
- if (GetPlayerVehicleSeat(i) == 0) { //if the player is a driver (it should only lower the fuel when theres an driver!)
- fuel[vid] = fuel[vid] -1; //lowering fuel value
- if (fuel[vid]<1) //if fuel is empty
- {
- fuel[vid] = 0; //setting fuel to 0 (else the timer will set it to -1 -2 -3 etc before removing player)
- SetVehicleParamsEx(vid,0,0,alarm,doors,bonnet,boot,objective);
- GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",2500,4); //show text
- }
- }
- new string[125];format(string,sizeof string,"Fuel: %i",fuel[vid]); //preparing string with next fuel value
- TextDrawSetString(td_fuel[i],string); //updating textdraw
- new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed,final_speed,Float:health;
- GetVehicleVelocity(vid,speed_x,speed_y,speed_z);
- temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
- final_speed = floatround(temp_speed,floatround_round);
- format(string,sizeof string,"Speed: %i",final_speed);
- TextDrawSetString(sdisplay[i],string);
- GetVehicleHealth(vid,health);
- if (max_vhealth[vid] == 0)//if its an random spawned vehicle
- {
- fuel[vid] = 400;
- GetVehicleHealth(vid,max_vhealth[vid]);
- }
- health = (((health - max_vhealth[vid]) /max_vhealth[vid]) *100)+ 100;
- format(string,sizeof string,"Health: %i",floatround(health,floatround_round));
- TextDrawSetString(td_vhealth[i],string);
- }
- return 1;
- }
- public timer_refuel(playerid)
- {
- new vid = GetPlayerVehicleID(playerid);
- fuel[vid] = fuel[vid] = 400;
- isrefuelling[playerid] = 0;
- TextDrawSetString(td_fuel[playerid],"Fuel:100");
- TogglePlayerControllable(playerid,1);
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- CheckpointEntered(playerid);
- return 1;
- }
- stock CheckpointEntered(playerid)
- {
- new gString[128];//A new string for storage
- new vID = GetPlayerVehicleID(playerid);//Explained earlier
- if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_RED, "You need a trailer to unload!");//This line checks wether the player has a trailer attached to their truck.
- if(MissionStatus[playerid] == 1)//checks the players mission status
- {
- DisablePlayerCheckpoint(playerid);//disables the checkpoint
- SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);//creates the new checkpoint from the saved positions we made earlier
- SendClientMessage(playerid, COLOR_ORANGE, "Loaded. Please head to the second checkpoint!");//sends message
- MissionStatus[playerid] = 2;//sets the players mission status
- }
- else if(MissionStatus[playerid] == 2)//checks the mission status of the player
- {
- DisablePlayerCheckpoint(playerid);//disables the checkpoint
- GivePlayerMoney(playerid, iPay[playerid]);//gives the money that was defined earlier
- SendClientMessage(playerid, COLOR_GREEN, "Well done! You completed the mission!");//sends the player a message
- format(gString, 512, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);//formats the message
- SendClientMessageToAll(COLOR_GREEN, gString);//sends everyone message saying player completed mission
- SetPlayerScore(playerid, GetPlayerScore(playerid)+2);//gives the player 2 score
- MissionStatus[playerid] = 0;//sets the mission status of the player to '0'
- }
- 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_SUBMISSION))//If the player pressed KEY_SUBMISSION (2)
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)//Checks if the player is the driver
- {
- new vehicle = GetPlayerVehicleID(playerid);//Getting the players vehicle id.
- new engine,lights,alarm,doors,bonnet,boot,objective;//The vehicle params
- GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);//Getting the vehicle params
- if(engine == 0)//If the engine is off
- {
- SetVehicleParamsEx(vehicle,1,1,alarm,doors,bonnet,boot,objective);//We turn on the engine and lights
- SendClientMessage(playerid,-1,"You started the engine!");
- }
- else//Else is the engine is on
- {
- SetVehicleParamsEx(vehicle,0,0,alarm,doors,bonnet,boot,objective);//We turn off the engine and lights
- SendClientMessage(playerid,-1,"You stopped the engine!");//Sends a message to the player telling him he stopped the engine.
- }
- return 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[])
- {
- if(dialogid == dregister) //If dialog id is a register dialog
- {//then
- if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
- if(response) //if they clicked the first button "Register"
- {//then
- if(!strlen(inputtext)) //If they didn't enter any password
- {// then we will tell to them to enter the password to register
- ShowPlayerDialog(playerid,dregister,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;
- }
- //If they have entered a correct password for his/her account...
- new hashpass[129]; //Now we will create a new variable to hash his/her password
- WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
- new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
- INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
- INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
- INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
- INI_WriteInt(file,"VIPLevel",0);//As explained above
- INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
- INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
- INI_WriteInt(file,"Kills",0);//As explained above
- INI_WriteInt(file,"Deaths",0);//As explained above
- INI_Close(file);//Now after we've done saving their data, we now need to close the file
- SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
- return 1;
- }
- }
- if(dialogid == dlogin) //If dialog id is a login dialog
- {//then
- if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
- if(response) //if they clicked the first button "Register"
- {//then
- new hashpass[129]; //Will create a new variable to hash his/her password
- WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
- if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
- {//then
- INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
- SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
- GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
- SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
- }
- else //If they've entered an incorrect password
- {//then
- ShowPlayerDialog(playerid,dlogin,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;
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //------------------------------------------------------------------------------- STOCKS ETC ----------------------------------------//
- SetPlayerTeamFromClass(playerid, classid)
- {
- if (classid == 0)
- {
- gTeam[playerid] = TEAM_TRUCKER;
- GameTextForPlayer(playerid, "~r~ Trucker", 5500, 5);
- }
- else
- {
- gTeam[playerid] = TEAM_POLICE;
- GameTextForPlayer(playerid, "~b~ Police", 5500, 5);
- }
- }
- SetPlayerToTeamColor(playerid)
- {
- if (gTeam[playerid] == TEAM_TRUCKER)
- {
- SetPlayerColor(playerid, COLOR_ORANGE);
- }
- else if (gTeam[playerid] == TEAM_POLICE)
- {
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- stock pName( playerid )
- {
- new Name[ MAX_PLAYER_NAME ];
- GetPlayerName( playerid, Name, sizeof( Name ) );
- return Name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement