All pastes #930648 Raw Edit

[FS] Deathmatch Script with Exa

public text v1 · immutable
·published 2008-03-06 19:21 UTC
rendered paste body
/*
	Deathmatch class selection example Script by G-sTyLeZzZ
	I got the idea from a German community member
*/


#include <a_samp>

#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GRAD1 0xB4B5B7AA

#pragma tabsize 0

new Skin[MAX_PLAYERS];
new Skinactive[MAX_PLAYERS];
new Skintimer[MAX_PLAYERS];
new InDm[MAX_PLAYERS];
new Text:hilfe1;
new Text:hilfe2;
new Text:copyright;

new Float:dmexit[5][3] = {
{2386.0974,989.1138,10.8203},
{2029.5751,1007.7642,10.8203},
{2294.7498,2421.5452,10.8203},
{2017.6318,1545.4016,10.8292},
{2036.8822,1932.5518,12.1310}
};

new Float:DMSpawns[8][3] = {
{166.4067,1923.9584,18.4408},
{178.3397,1886.7275,20.4317},
{197.1122,1859.0555,20.6406},
{253.9827,1877.2373,20.4743},
{243.8657,1919.5469,17.6406},
{193.4239,1919.4771,17.6406},
{162.0484,1931.0018,33.8984},
{214.4687,1875.1614,13.1470}
};

forward DMSelection(playerid);



public OnFilterScriptInit( )
{
	print( "\n************************" );
	print( "  * Class Selection      *" );
	print( "  * Loaded by G_sTyLeZzZ *" );
	print( " *************************\n" );
	hilfe1 = TextDrawCreate(134.000000,326.000000,"Use the arrows < > to select another Skin");
	TextDrawAlignment(hilfe1,0);
	TextDrawBackgroundColor(hilfe1,0x000000ff);
	TextDrawFont(hilfe1,0);
	TextDrawLetterSize(hilfe1,0.699999,2.200000);
	TextDrawColor(hilfe1,0xffffffff);
	TextDrawSetOutline(hilfe1,1);
	TextDrawSetProportional(hilfe1,1);
	TextDrawSetShadow(hilfe1,1);
	hilfe2 = TextDrawCreate(146.000000,351.000000,"   Press ~r~Tab ~w~to choose the current ~b~Skin");
	copyright = TextDrawCreate(388.000000,381.000000,"(C) by G_sTyLeZzZ");
	TextDrawAlignment(hilfe2,0);
	TextDrawAlignment(copyright,0);
	TextDrawBackgroundColor(hilfe2,0x000000ff);
	TextDrawBackgroundColor(copyright,0x000000ff);
	TextDrawFont(hilfe2,0);
	TextDrawLetterSize(hilfe2,0.699999,2.000000);
	TextDrawFont(copyright,3);
	TextDrawLetterSize(copyright,0.299999,1.100000);
	TextDrawColor(hilfe2,0xffffffff);
	TextDrawColor(copyright,0xffffffff);
	TextDrawSetOutline(hilfe2,1);
	TextDrawSetOutline(copyright,1);
	TextDrawSetProportional(hilfe2,1);
	TextDrawSetProportional(copyright,1);
	TextDrawSetShadow(hilfe2,1);
	TextDrawSetShadow(copyright,1);
	return 1;
}


public OnPlayerConnect(playerid)
{
	Skin[playerid] = 0;
	Skinactive[playerid] = 0;
	InDm[playerid] = 0;
	return 1;
}


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 OnPlayerDeath(playerid, killerid, reason)
{
	new pname[MAX_PLAYER_NAME];
	new string[256];
	new deathreason[20];
	GameTextForPlayer(playerid,"~r~OWNED",10000,1);
	GetPlayerName(playerid, pname, sizeof(pname));
	GetWeaponName(reason, deathreason, 20);
	if (killerid == INVALID_PLAYER_ID)
	{
		if (reason == WEAPON_DROWN)
		{
			format(string, sizeof(string), "*** %s sanked.", pname);
		}
		else
		{
			if (strlen(deathreason) > 0)
			{
				format(string, sizeof(string), "*** %s got owned (%s)", pname, deathreason);
			}
			else
			{
				format(string, sizeof(string), "*** %s got owned.", pname);
			}
 	 	}
	}
	else
	{
		new killer[MAX_PLAYER_NAME];
		GetPlayerName(killerid, killer, sizeof(killer));
		if (strlen(deathreason) > 0)
		{
			format(string, sizeof(string), "*** %s owned %s. (%s)", killer, pname, deathreason);
		}
		else
		{
			format(string, sizeof(string), "*** %s owned %s.", killer, pname);
		}
	}
	SendClientMessageToAll(COLOR_GRAD1, string);
	return 1;
}

public DMSelection(playerid)
{
    new keys, updown, leftright;
    GetPlayerKeys(playerid, keys, updown, leftright);
    
    
    if(leftright == KEY_RIGHT)
    {
        if(Skin[playerid] == 1)
        {
			SetPlayerSkin(playerid,285);
			Skin[playerid]++;
			GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if (Skin[playerid] == 2)
		{
		    SetPlayerSkin(playerid,286);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
		else if (Skin[playerid] == 3)
		{
		    SetPlayerSkin(playerid, 287);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 4)
		{
		    SetPlayerSkin(playerid, 288);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
		else if(Skin[playerid] == 5)
		{
		    SetPlayerSkin(playerid, 280);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 6)
		{
		    SetPlayerSkin(playerid, 281);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
		else if(Skin[playerid] == 7)
		{
		    SetPlayerSkin(playerid, 282);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 8)
		{
		    SetPlayerSkin(playerid,283);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
		else if(Skin[playerid] == 9)
		{
		    SetPlayerSkin(playerid,284);
		    Skin[playerid]++;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 10) // letztes skin
		{
		    SetPlayerSkin(playerid,285);
		    Skin[playerid] = 1;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
	}
	
	if(leftright == KEY_LEFT)
	{
	    if(Skin[playerid] == 10)
	    {
	        SetPlayerSkin(playerid, 284);
	        Skin[playerid]--;
	        GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 9)
		{
		    SetPlayerSkin(playerid, 283);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 8)
		{
		    SetPlayerSkin(playerid, 282);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 7)
		{
		    SetPlayerSkin(playerid, 281);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
		else if(Skin[playerid] == 6)
		{
		    SetPlayerSkin(playerid, 280);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 5)
		{
		    SetPlayerSkin(playerid, 288);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
		else if(Skin[playerid] == 4)
		{
		    SetPlayerSkin(playerid, 287);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 3)
		{
		    SetPlayerSkin(playerid, 286);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
		else if(Skin[playerid] == 2)
		{
		    SetPlayerSkin(playerid, 285);
		    Skin[playerid]--;
		    GameTextForPlayer(playerid, "Swat",500,1);
		}
		else if(Skin[playerid] == 1)
		{
		    SetPlayerSkin(playerid, 284);
		    Skin[playerid] = 10;
		    GameTextForPlayer(playerid, "Police",500,1);
		}
	}
	
	if(keys & KEY_ACTION || keys & KEY_CROUCH)
	{
	    Skin[playerid] = 0;
	    Skinactive[playerid] = 0;
	    TogglePlayerControllable(playerid, true);
		new randomize=random(sizeof(DMSpawns));
   		SetPlayerPos(playerid, DMSpawns[randomize][0],DMSpawns[randomize][1],DMSpawns[randomize][2]);
   		SetCameraBehindPlayer(playerid);
   		KillTimer(Skintimer[playerid]);
   		TextDrawHideForPlayer(playerid, hilfe1);
		TextDrawHideForPlayer(playerid, hilfe2);
		TextDrawHideForPlayer(playerid, copyright);
		SetPlayerWorldBounds(playerid, 315.3026, 105.1009, 1926.849, 1775.037);
	}
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	KillTimer(Skintimer[playerid]);
	return 1;
}

public OnPlayerSpawn(playerid)
{
	if(InDm[playerid] == 1)
	{
		new randomize=random(sizeof(DMSpawns));
   		SetPlayerPos(playerid, DMSpawns[randomize][0],DMSpawns[randomize][1],DMSpawns[randomize][2]);
   		SetCameraBehindPlayer(playerid);
   		SendClientMessage(playerid, COLOR_YELLOW,"If you want to exit the Deathmatch use /exit !");
	}
	return 1;
}
	

public OnPlayerCommandText(playerid, cmdtext[])
{
	new idx;
	new cmd[256];
	cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/dm", true) == 0)
{
	if(InDm[playerid] == 1)
	{
	    SendClientMessage(playerid, COLOR_YELLOW,"You are already in the Deathmatch");
	    return 1;
	}
	else
	{
		new pname[256];
		GetPlayerName(playerid, pname, sizeof(pname));
		format(pname,sizeof(pname),"*** %s (ID: %d) has entered the Deatmatcharea: /dm",pname,playerid);
	   	SendClientMessageToAll(COLOR_YELLOW,pname);
		TogglePlayerControllable(playerid, false);
		SetPlayerPos(playerid, 232.2091,1935.0380,33.8984);
		SetPlayerFacingAngle(playerid, 90);
		SetPlayerCameraPos(playerid,232.2091-1.5,1935.0380,33.8984+0.7);
		SetPlayerCameraLookAt(playerid,232.2091,1935.0380,33.8984+0.7);
		SetPlayerSkin(playerid, 284);
		Skin[playerid] = 1;
		Skinactive[playerid] = 1;
		InDm[playerid] = 1;
		Skintimer[playerid] = SetTimerEx("DMSelection", 200, 1, "i", playerid);
		TextDrawShowForPlayer(playerid, hilfe1);
		TextDrawShowForPlayer(playerid, hilfe2);
		TextDrawShowForPlayer(playerid, copyright);
	}
	return 1;
}

if(strcmp(cmd, "/exit") == 0)
{
	if(InDm[playerid] == 0)
	{
	    SendClientMessage(playerid, COLOR_YELLOW,"You are not at the Deathmatch Zone!");
	    return 1;
	}
	else
	{
		new randomize=random(sizeof(dmexit));
		SetPlayerPos(playerid, dmexit[randomize][0],dmexit[randomize][1],dmexit[randomize][2]);
		//SetPlayerHealth(playerid, 100.0);
		ResetPlayerWeapons(playerid);
		InDm[playerid] = 0;
		SetPlayerWorldBounds(playerid, 3001.214, -2977.858, 2989.536, -2989.536);
	}
	return 1;
}

	return 0;
}