Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- R@f : Créator
- Syg : Hay tower créator
- Fullmetal : Tester
- Keyman : /specplayer command
- All the SA-MP team for creating this Multiplayer mod
- */
- #include <a_samp>
- #include <core>
- #include <float>
- forward TimerMove ();
- forward TimerScore ();
- forward TimerFini (id, x, y, z);
- forward TDScore ();
- forward DelayedGmx();
- forward DelayedGmx2();
- #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 Text:Score[MAX_PLAYERS];
- main()
- {
- print("\n-------------------------------------------");
- print(" Hay GameMode for SA-MP 1.0 by R@f and Syg");
- print("-------------------------------------------\n");
- }
- //==============================================================================
- public OnGameModeInit()
- {
- SetGameModeText("Hay 1.0");
- 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[128];
- new pname[128];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(string, sizeof(string), "*** %s has joined the server", pname);
- SendClientMessageToAll(COLOR_GREY, string);
- GameTextForPlayer(playerid,"~w~]~b~H~r~A~g~Y~y~ 1.0~w~]",2500,5);
- SetPlayerColor(playerid, COLOR_GREY);
- return 1;
- }
- //==============================================================================
- public OnPlayerDisconnect(playerid, reason)
- {
- new pname[128], string[128];
- GetPlayerName(playerid, pname, sizeof(pname));
- TextDrawHideForPlayer(playerid, Score[playerid]);
- 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)
- {
- 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 DelayedGmx()
- {
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- TextDrawHideForPlayer(i, Score[i]);
- }
- SetTimer("DelayedGmx2",5000, false);
- return 1;
- }
- public DelayedGmx2()
- {
- GameModeExit();
- }
- //==============================================================================
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[128];
- new specplayerid,idx;
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmdtext, "/acmds", true) == 0 && IsPlayerAdmin(playerid))
- {
- 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");
- return 1;
- }
- if(strcmp(cmdtext, "/gmx", true) == 0 && IsPlayerAdmin(playerid))
- {
- SetTimer("DelayedGmx",5000,false);
- return 1;
- }
- if(strcmp(cmdtext, "/hay", true) == 0 && IsPlayerAdmin(playerid))
- {
- NettoyerTourDePaille();
- InitialiserTourPaille ();
- 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,"/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");
- return 1;
- }
- if(strcmp(cmdtext, "/kill", true) == 0)
- {
- SetPlayerHealth(playerid,0);
- 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, "/specplayer", true) == 0)
- {
- new tmp[128];
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /specplayer [playerid]");
- }
- specplayerid = strval(tmp);
- if(!IsPlayerConnected(specplayerid))
- {
- return SendClientMessage(playerid, COLOR_GREY, "[ERROR] that player isn't active.");
- }
- 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<MAX_PLAYERS ; i++)
- {
- if (IsPlayerConnected (i))
- {
- SetPlayerScore (i, 0);
- }
- }
- for (x=0 ; x<PAILLE_X ; x++)
- {
- for (y=0 ; y<PAILLE_Y ; y++)
- {
- for (z=0 ; z<PAILLE_Z ; z++)
- {
- Matrice[x][y][z] = 0;
- }
- }
- }
- for (Compte=0 ; Compte<PAILLE_B ; Compte++)
- {
- do
- {
- x = random (PAILLE_X);
- y = random (PAILLE_Y);
- z = random (PAILLE_Z);
- }
- while (Matrice[x][y][z] != 0);
- Matrice[x][y][z] = 1;
- Bottes[Compte] = CreateObject (ID_HAY_OBJECT, x*(-4), y*(-4), (z+1)*3, 0.0, 0.0, random (2)*180);
- }
- for (Compte=0 ; Compte<PAILLE_R ; Compte++)
- {
- do
- {
- x = random (PAILLE_X);
- y = random (PAILLE_Y);
- z = random (PAILLE_Z);
- }
- while (Matrice[x][y][z] != 0);
- Matrice[x][y][z] = 1;
- Rochers[Compte] = CreateObject (ID_ROCK_OBJECT, x*-4, y*-4, (z+1)*3, random (360), random (360), random (360));
- }
- Centre_x = (PAILLE_X + 1) * -2;
- Centre_y = (PAILLE_Y + 1) * -2;
- BotteDuHaut = CreateObject (ID_HAY_OBJECT, Centre_x, Centre_y, PAILLE_Z*3 + 3, 0, 0, 0);
- SetTimer ("TimerMove", 100, 0);
- }
- //==============================================================================
- NettoyerTourDePaille ()
- {
- for (new i=0 ; i<PAILLE_B ; i++)
- {
- DestroyObject (Bottes[i]);
- }
- DestroyObject (BotteDuHaut);
- for (new i=0 ; i<PAILLE_R ; i++)
- {
- DestroyObject (Rochers[i]);
- }
- }
- //==============================================================================
- public TimerMove ()
- {
- new rand;
- new Botte;
- new Move;
- new x, y, z;
- new Float:x2, Float:y2, Float:z2;
- new Temps;
- new Float:Speed;
- do
- {
- rand = random (PAILLE_B);
- }
- while (EnDeplacement[rand] == 1);
- Botte = Bottes[rand];
- Move = random (6);
- GetObjectPos (Botte, x2, y2, z2);
- x = floatround (x2/-4.0);
- y = floatround (y2/-4.0);
- z = floatround (z2/3.0)-1;
- if ((Move == 0) && (x != 0) && (Matrice[x-1][y][z] == 0))
- {
- EnDeplacement[rand] = 1;
- Temps = 4000 - Vitesse_xy * z;
- Speed = SPEED_FACTOR / float (Temps);
- SetTimerEx ("TimerFini", Temps, 0, "iiii", rand, x, y, z);
- x = x - 1;
- Matrice[x][y][z] = 1;
- MoveObject (Botte, x2+4.0, y2, z2, Speed);
- }
- else if ((Move == 1) && (x != PAILLE_X-1) && (Matrice[x+1][y][z] == 0))
- {
- EnDeplacement[rand] = 1;
- Temps = 4000 - Vitesse_xy * z;
- Speed = SPEED_FACTOR / float (Temps);
- SetTimerEx ("TimerFini", Temps, 0, "iiii", rand, x, y, z);
- x = x + 1;
- Matrice[x][y][z] = 1;
- MoveObject (Botte, x2-4.0, y2, z2, Speed);
- }
- else if ((Move == 2) && (y != 0) && (Matrice[x][y-1][z] == 0))
- {
- EnDeplacement[rand] = 1;
- Temps = 4000 - Vitesse_xy * z;
- Speed = SPEED_FACTOR / float (Temps);
- SetTimerEx ("TimerFini", Temps, 0, "iiii", rand, x, y, z);
- y = y - 1;
- Matrice[x][y][z] = 1;
- MoveObject (Botte, x2, y2+4.0, z2, Speed);
- }
- else if ((Move == 3) && (y != PAILLE_Y-1) && (Matrice[x][y+1][z] == 0))
- {
- EnDeplacement[rand] = 1;
- Temps = 4000 - Vitesse_xy * z;
- Speed = SPEED_FACTOR / float (Temps);
- SetTimerEx ("TimerFini", Temps, 0, "iiii", rand, x, y, z);
- y = y + 1;
- Matrice[x][y][z] = 1;
- MoveObject (Botte, x2, y2-4.0, z2, Speed);
- }
- else if ((Move == 4) && (z != 0) && (Matrice[x][y][z-1] == 0))
- {
- EnDeplacement[rand] = 1;
- Temps = 3000 - Vitesse_z * z;
- Speed = SPEED_FACTOR / float (Temps);
- SetTimerEx ("TimerFini", Temps, 0, "iiii", rand, x, y, z);
- z = z - 1;
- Matrice[x][y][z] = 1;
- MoveObject (Botte, x2, y2, z2-3.0, Speed);
- }
- else if ((Move == 5) && (z != PAILLE_Z-1) && (Matrice[x][y][z+1] == 0))
- {
- EnDeplacement[rand] = 1;
- Temps = 3000 - Vitesse_z * z;
- Speed = SPEED_FACTOR / float (Temps);
- SetTimerEx ("TimerFini", Temps, 0, "iiii", rand, x, y, z);
- z = z + 1;
- Matrice[x][y][z] = 1;
- MoveObject (Botte, x2, y2, z2+3.0, Speed);
- }
- SetTimer ("TimerMove", 100, 0);
- }
- //==============================================================================
- public TimerFini (id, x, y, z)
- {
- EnDeplacement[id] = 0;
- Matrice[x][y][z] = 0;
- }
- //==============================================================================
- public TimerScore ()
- {
- new Float:x, Float:y, Float:z;
- for (new i=0 ; i<MAX_PLAYERS ; i++)
- {
- if (IsPlayerConnected (i))
- {
- GetPlayerPos (i, x, y, z);
- if (x<=2.0 && x>=-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<MAX_PLAYERS ; i++)
- {
- if(IsPlayerConnected(i))
- {
- Level = GetPlayerScore(i);
- format(string,sizeof(string),"YOURE LEVEL: %d",Level);
- TextDrawSetString(Score[i], string);
- }
- if(GetPlayerScore(i) == 31)
- {
- GetPlayerName(i, PlayerName, sizeof(PlayerName));
- format(string, sizeof(string),"]]]]]~n~%s is at the top of the hay tower~n~]]]]]", PlayerName);
- GameTextForAll(string,2500,4);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement