//-------=====-------=====-----=================-----=====-------=====---------- //-------=====-------=====-----=================------=====-----=====----------- //-------=====-------=====-----=====-------=====-------=====---=====------------ //-------=====-------=====-----=====-------=====--------=====-=====------------- //-------=================-----=================----------=====----------------- //-------=================-----=================---------=====------------------ //-------=====-------=====-----=====-------=====--------=====------------------- //-------=====-------=====-----=====-------=====-------=====-------------------- //-------=====-------=====-----=====-------=====------=====--------------------- //-------=====-------=====-----=====-------=====-----=====-------------by R@f ©- /* R@f : Créator Syg : Hay tower créator Fullmetal : Tester Kyeman : /specplayer command Sneaky! : score TextDraw All the SA-MP team for creating this Multiplayer mod */ #include #include #include forward TimerMove (); forward TimerScore (); forward TimerFini (id, x, y, z); forward TDScore (); forward RespawnJoueur (playerid); forward TimerDeRespawn (playerid); forward HayAC (); forward Unfreeze (playerid); #define COLOR_GREY 0xAFAFAFAA #define COLOR_GREEN 0x33AA33AA #define PAILLE_X 4 #define PAILLE_Y 4 #define PAILLE_Z 30 #define PAILLE_B 146 #define PAILLE_R 4 #define SPEED_FACTOR 3000.0 #define ID_HAY_OBJECT 3374 #define ID_ROCK_OBJECT 1305 #define ADMIN_SPEC_TYPE_NONE 0 #define ADMIN_SPEC_TYPE_PLAYER 1 new gSpectateID[MAX_PLAYERS]; new gSpectateType[MAX_PLAYERS]; new Vitesse_xy; new Vitesse_z; new Centre_x; new Centre_y; new Matrice[PAILLE_X][PAILLE_Y][PAILLE_Z]; new Bottes[PAILLE_B]; new Rochers[PAILLE_B]; new EnDeplacement[PAILLE_B]; new BotteDuHaut; new HAC; new Text:Score[MAX_PLAYERS]; new Text:Mort; main() { print("\n-------------------------------------------"); print(" Hay GameMode for SA-MP 1.1 by R@f and Syg"); print("-------------------------------------------\n"); } //============================================================================== public OnGameModeInit() { SetGameModeText("Hay 1.1"); UsePlayerPedAnims(); InitialiserTourPaille (); SetTimer ("TimerScore", 200, 1); SetTimer ("TDScore", 600, 1); AddPlayerClass(0, 35.0, 6.5, 3.2, 135.1425, 0, 0, 0, 0, 0, 0); AddPlayerClass(29, 35.0, 6.5, 3.2, 135.1425, 0, 0, 0, 0, 0, 0); AddPlayerClass(188, 35.0, 6.5, 3.2, 135.1425, 0, 0, 0, 0, 0, 0); return 1; } //============================================================================== public OnPlayerRequestClass(playerid, classid) { SetPlayerPos(playerid, -8.6413,-8.4667,95.5060); SetPlayerFacingAngle(playerid,269.1425); SetPlayerCameraPos(playerid, -0.8600,-0.4655,97.1056); SetPlayerCameraLookAt(playerid, -8.6413,-8.4667,95.5060); ApplyAnimation(playerid,"DANCING","DNCE_M_A",4.0,1,0,0,0,-1); PlayerPlaySound(playerid,1062, 0.0, 0.0, 0.0); switch (classid) { case 0: { GameTextForPlayer(playerid, "~g~CJ", 1500, 3); } case 1: { GameTextForPlayer(playerid, "~w~Raf", 1500, 3); } case 2: { GameTextForPlayer(playerid, "~w~Syg", 1500, 3); } } return 1; } //============================================================================== public OnPlayerConnect(playerid) { new string[256], pname[250]; GetPlayerName(playerid, pname, sizeof(pname)); format(string, sizeof(string), "**** %s has joined the server ****", pname); SendClientMessageToAll(COLOR_GREY, string); format(string, sizeof(string), "Welcome %s on the hay server scripted by R@f and Syg ", pname); SendClientMessage(playerid,COLOR_GREY, string); SendClientMessage(playerid,COLOR_GREY, "if you want to see the commands, write /cmds"); GameTextForPlayer(playerid,"~w~]~b~H~r~A~g~Y~y~ 1.1~w~]",2500,5); SetPlayerColor(playerid, COLOR_GREY); return 1; } //============================================================================== public OnPlayerDisconnect(playerid, reason) { new pname[400], string[500]; GetPlayerName(playerid, pname, sizeof(pname)); if(reason == 0) { format(string, sizeof(string), "**** %s left the server. (Timeout) ****", pname); SendClientMessageToAll(COLOR_GREY, string); print(string); } else if(reason == 1) { format(string, sizeof(string), "**** %s left the server. (Leaving...) ****", pname); SendClientMessageToAll(COLOR_GREY, string); print(string); } else if(reason == 2) { format(string, sizeof(string), "**** %s left the server. (Kicked/Banned) ****", pname); SendClientMessageToAll(COLOR_GREY, string); print(string); } return 1; } //============================================================================== public OnPlayerDeath(playerid, killerid, reason) { SetTimerEx("TimerDeRespawn", 3725, 0, "i", playerid); SendDeathMessage(killerid,playerid,reason); TextDrawHideForPlayer(playerid, Score[playerid]); TextDrawDestroy(Score[playerid]); return 1; } //============================================================================== public OnPlayerSpawn(playerid) { Score[playerid] = TextDrawCreate(20.0,425.0," "); TextDrawAlignment(Score[playerid],0); TextDrawBackgroundColor(Score[playerid],0x000000ff); TextDrawFont(Score[playerid],1); TextDrawLetterSize(Score[playerid],0.5,1.5); TextDrawColor(Score[playerid],0xffffffcc); TextDrawSetOutline(Score[playerid],1); TextDrawSetProportional(Score[playerid],1); TextDrawSetShadow(Score[playerid],1); TextDrawShowForPlayer(playerid, Score[playerid]); PlayerPlaySound (playerid, 1063, 0.0, 0.0, 0.0); SetPlayerWorldBounds(playerid, 116.7788, -70.06725, 105.1009, -116.7788); return 1; } //============================================================================== public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256],specplayerid,idx,pid,PidName[MAX_PLAYER_NAME]; cmd = strtok(cmdtext, idx); if(IsPlayerAdmin(playerid)) { if(strcmp(cmdtext, "/acmds", true) == 0) { SendClientMessage(playerid,COLOR_GREEN,"***Hay GameMode for SA-MP***"); SendClientMessage(playerid,COLOR_GREEN,"/gmx : restart the GM"); SendClientMessage(playerid,COLOR_GREEN,"/hay : rebuild the hay tower"); SendClientMessage(playerid,COLOR_GREEN,"/acon : switch the Hay Anti-Cheat ON"); SendClientMessage(playerid,COLOR_GREEN,"/acoff : switch the Hay Anti-Cheat OFF"); return 1; } if(strcmp(cmdtext, "/gmx", true) == 0) { SendRconCommand("gmx"); return 1; } if(strcmp(cmdtext, "/hay", true) == 0) { NettoyerTourDePaille(); InitialiserTourPaille (); return 1; } if(strcmp(cmdtext, "/acon", true) == 0) { HAC = SetTimer("HayAC",1000,1); SendClientMessage(playerid,COLOR_GREEN,"HAC : Anti-cheat On"); print("HAC : Anti-cheat On"); return 1; } if(strcmp(cmdtext, "/acoff", true) == 0) { KillTimer(HAC); SendClientMessage(playerid,COLOR_GREEN,"HAC : Anti-cheat Off"); print("HAC : Anti-cheat Off"); return 1; } } if(strcmp(cmdtext, "/help", true) == 0) { SendClientMessage(playerid,COLOR_GREEN,"***Hay GameMode for SA-MP***"); SendClientMessage(playerid,COLOR_GREEN,"For a list of the commands write /cmds"); SendClientMessage(playerid,COLOR_GREEN,"For the list of the credits write /credits"); return 1; } // if(strcmp(cmdtext, "/cmds", true) == 0) { SendClientMessage(playerid,COLOR_GREEN,"***Hay GameMode for SA-MP***"); SendClientMessage(playerid,COLOR_GREEN,"/kill : Kill your self"); SendClientMessage(playerid,COLOR_GREEN,"/score : Look your score or an player score"); SendClientMessage(playerid,COLOR_GREEN,"/specplayer : Spec a player"); SendClientMessage(playerid,COLOR_GREEN,"/specoff : Turn the specplayer off"); SendClientMessage(playerid,COLOR_GREEN,"/cam : Show the hay tower"); SendClientMessage(playerid,COLOR_GREEN,"/spawn : Spawn at your spawn point"); SendClientMessage(playerid,COLOR_GREEN,"/acmds : See admin commands (Admin Only)"); return 1; } // if(strcmp(cmdtext, "/credits", true) == 0) { SendClientMessage(playerid,COLOR_GREEN,"***Hay GameMode for SA-MP***"); SendClientMessage(playerid,COLOR_GREEN,"This GameMode is scripted by R@f and Syg"); SendClientMessage(playerid,COLOR_GREEN,"Special thanks to Syg for the hay script"); SendClientMessage(playerid,COLOR_GREEN,"Thanks to Kyeman for his Specplayer"); SendClientMessage(playerid,COLOR_GREEN,"And Sneaky! for the score TextDraw"); return 1; } // if(strcmp(cmdtext, "/kill", true) == 0) { SetPlayerHealth(playerid,-9999); return 1; } // if(strcmp(cmdtext, "/spawn", true) == 0) { SpawnPlayer(playerid); return 1; } // if(strcmp(cmdtext, "/cam", true) == 0) { TogglePlayerControllable(playerid,0); SetPlayerCameraPos(playerid, 32.9946,47.2079,78.5389); SetPlayerCameraLookAt(playerid, -5.6487,1.4449,50.5060); SendClientMessage(playerid,COLOR_GREEN,"Write /spawn to exit this view"); return 1; } // if(strcmp(cmd, "/score", true) == 0) { new tmp[256],PidScore; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GREEN, "USAGE: /score [playerid]"); return 1; } pid = strval(tmp); if(!IsPlayerConnected(pid)) { SendClientMessage(playerid, COLOR_GREY, "[ERROR] that player isn't active."); return 1; } PidScore = GetPlayerScore(pid); GetPlayerName(pid, PidName, sizeof(PidName)); format(tmp, sizeof(tmp),"%s(ID:%d) level is : %d",PidName,pid,PidScore); SendClientMessage(playerid,COLOR_GREEN,tmp); return 1; } // if(strcmp(cmd, "/specplayer", true) == 0) { new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GREEN, "USAGE: /specplayer [playerid]"); return 1; } specplayerid = strval(tmp); if(!IsPlayerConnected(specplayerid)) { SendClientMessage(playerid, COLOR_GREY, "[ERROR] that player isn't active."); return 1; } TogglePlayerSpectating(playerid, 1); SetPlayerInterior(playerid,GetPlayerInterior(specplayerid)); gSpectateID[playerid] = specplayerid; gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER; return 1; } // if(strcmp(cmd, "/specoff", true) == 0) { TogglePlayerSpectating(playerid, 0); gSpectateID[playerid] = INVALID_PLAYER_ID; gSpectateType[playerid] = ADMIN_SPEC_TYPE_NONE; return 1; } return 0; } //============================================================================== InitialiserTourPaille () { new x, y, z; new Compte; Vitesse_xy = 2000 / (PAILLE_Z + 1); Vitesse_z = 1500 / (PAILLE_Z + 1); for (new i=0 ; i=-15.0 && y<=2.0 && y>=-15.0) { new Level = (floatround (z)/3) - 1; SetPlayerScore (i, Level); } else { SetPlayerScore (i, 0); } } } } //============================================================================== strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; } //============================================================================== public TDScore() { new Level; new string[128]; new PlayerName[MAX_PLAYER_NAME]; for (new i=0 ; i 101) { GetPlayerName(i, PlayerName, sizeof(PlayerName)); format(string, sizeof(string),"HAC: %s (ID:%d) has been kicked from the server (Reason : Health Hack)", PlayerName,i); SendClientMessageToAll(COLOR_GREY,string); print(string); Kick(i); } else if(GetPlayerWeapon(i) > 2) { GetPlayerName(i, PlayerName, sizeof(PlayerName)); format(string, sizeof(string),"HAC: %s (ID:%d) has been kicked from the server (Reason : Weapons hack)", PlayerName,i); SendClientMessageToAll(COLOR_GREY,string); print(string); Kick(i); } else if(GetPlayerScore(i) > 32) { GetPlayerName(i, PlayerName, sizeof(PlayerName)); format(string, sizeof(string),"HAC: %s (ID:%d) has been kicked from the server (Reason : Invaild Score)", PlayerName,i); SendClientMessageToAll(COLOR_GREY,string); print(string); Kick(i); } else if(GetPlayerArmour(i,armour) > 1) { GetPlayerName(i, PlayerName, sizeof(PlayerName)); format(string, sizeof(string),"HAC: %s (ID:%d) has been kicked from the server (Reason : Armour hack)", PlayerName,i); SendClientMessageToAll(COLOR_GREY,string); print(string); Kick(i); } else if(GetPlayerMoney(i) > 1) { GetPlayerName(i, PlayerName, sizeof(PlayerName)); format(string, sizeof(string),"HAC: %s (ID:%d) has been kicked from the server (Reason : Money hack)", PlayerName,i); SendClientMessageToAll(COLOR_GREY,string); print(string); Kick(i); } //} } } } //============================================================================== public OnRconCommand(cmd[]) { if (!strcmp(cmd,"hacon")) { HAC = SetTimer("HayAC",1000,1); print("HAC : Anti-cheat On"); return 1; } if (!strcmp(cmd,"hacoff")) { KillTimer(HAC); print("HAC : Anti-cheat Off"); return 1; } return 0; } //============================================================================== public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if ((newkeys & KEY_FIRE)) { if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { TogglePlayerControllable(playerid,0); SetTimerEx("Unfreeze",1,0,"i",playerid); } } } //============================================================================== public Unfreeze(playerid) { TogglePlayerControllable(playerid,1); } //============================================================================== //============================================================================== //==============================================================================