Help with DM system
#1

Ok im new at scripting im just modifying a gamemode currently so i gain more experience
I made this dm command but have 2 problems with it,If you die you are not spawning in dm area ( it respawns in base) and the other one is that you still have same team before you joined dm and I don't know how i would set another team for it.

Here is the code i made:

Код:
new Float:DMSpawns[][4] =
        {
			//Dm spawns
		  {-974.3079,1061.1146,1345.6755,88.2162},
		  {-1052.9237,1024.6133,1343.1317,355.4687},
		  {-1063.7754,1096.8344,1343.1486,183.7607},
		  {-1132.2988,1057.7354,1346.4117,268.4739}
		};
new InDM[MAX_PLAYERS];
Код:
OnPlayerConnect
{
// dm
	InDM[playerid] = 0;
       return 1;
}

OnPlayerDisconnect
{
//dm
	InDM[playerid] = 0;
	return 1;
}
Код:
OnPlayerSpawn
{
  if(InDM[playerid] == 1)
    {
        SetPlayerInterior(playerid, 10); 
        SetPlayerVirtualWorld(playerid, 10);
        new rand = random(sizeof(DMSpawns)); 
        SetPlayerPos(playerid, DMSpawns[rand][0], DMSpawns[rand][1], DMSpawns[rand][2]);
        SetPlayerFacingAngle(playerid, DMSpawns[rand][3]);
		SetPlayerArmour(playerid, 99);
		SetPlayerHealth(playerid,99);
        GivePlayerWeapon(playerid, 24, 1500); // Desert Eagle
        GivePlayerWeapon(playerid, 27, 1500); // Combat Shotgun
        GivePlayerWeapon(playerid, 34, 1500); // Sniper
        GivePlayerWeapon(playerid, 31, 1500); // M4
        
    }
  return 1;
}
Код:
CMD:dm(playerid, params[])
{
	 new string[128];
     new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        if(InDM[playerid] == 0)
        {
            InDM[playerid] = 1;
            SendClientMessage(playerid, COLOR_ORANGE , "You have joined /dm, to leave type /dm again");
            format(string, sizeof(string), "Server: {FFFFFF}%s(%d) has joined DM(/dm)", PlayerName, playerid);
            SendClientMessageToAll(COLOR_LIGHTBLUE, string);
            SetPlayerInterior(playerid, 10);
            SetPlayerVirtualWorld(playerid, 10); 
            new rand = random(sizeof(DMSpawns));
            SetPlayerPos(playerid, DMSpawns[rand][0], DMSpawns[rand][1], DMSpawns[rand][2]);
            SetPlayerFacingAngle(playerid, DMSpawns[rand][3]);
            SetPlayerArmour(playerid, 99);
		    SetPlayerHealth(playerid,99);
            GivePlayerWeapon(playerid, 24, 1500); // Desert Eagle
            GivePlayerWeapon(playerid, 27, 1500); // Combat Shotgun
            GivePlayerWeapon(playerid, 34, 1500); // Sniper
            GivePlayerWeapon(playerid, 31, 1500); // M4
	   }
	   else {
            InDM[playerid] = 0; 
            SendClientMessage(playerid, COLOR_ORANGE, "You have left /dm to join again type /dm");
			SetPlayerHealth(playerid, 0);
			SetPlayerVirtualWorld(playerid, 0);
			ForceClassSelection(playerid);
			}
        return 1;
}
Reply
#2

Show your OnPlayerDeath.

And use SetPlayerTeam to change a player's team.
Reply
#3

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Show your OnPlayerDeath.

And use SetPlayerTeam to change a player's team.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new string[128];
	PlayerInfo[playerid][pPickupAble] = 0;
    KillTimer(justspawnedtimer[playerid]);
	DestroyVehicle(GetPVarInt(playerid, "RCc"));
    DeletePVar(playerid, "RCc");
    SetPVarInt(playerid, "NoAB", 4);
	for (new i=0;i<gMoneySpots;i++) if(gMoneySpot[i][msPlayer]==playerid) gMoneySpot[i][msPlayer]=-1;
	KillingSpree[playerid] = 0;
	CaptureSpree[playerid] = 0;
    if (killerid != INVALID_PLAYER_ID)
	{
		if(dueling[playerid])
		{
			SetPlayerHealth(playerid, 0);
			GameTextForPlayer(killerid,"~g~YOU WON THE DUEL!",3000,5);
			dueling[playerid]=0;
			dueling[killerid]=0;
			SetPVarInt(killerid, "NoAB", 4);
			SpawnPlayer(killerid);
			return 1;
		}
		else
		{
			String("~r~~h~You killed %s", gPlayerInfo[playerid][pName]);
			GameTextForPlayer(killerid, string, 1450, 6);
		}
		new weaponname[32], pname[30];
		GetPlayerName(killerid, pname, 24);
	    if(IsPlayerInAnyVehicle(killerid) && GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
		{
		    new vehicleid = GetPlayerVehicleID(killerid);
		    new modelid = GetVehicleModel(vehicleid);
   			format(string, sizeof string, "You have been killed by %s with a %s.",pname,VehicleNames[modelid-400]);
			SendClientMessage(playerid, COLOR_LIMEGREEN, string);
		}
		else
		{
			GetWeaponName(reason,weaponname,sizeof(weaponname));
			if(reason == 51 && !IsPlayerInAnyVehicle(killerid)) weaponname="explosive device";
			if(reason == 0) weaponname="fist";
			format(string, sizeof string, "You have been killed by %s with a %s.", pname, weaponname);
			SendClientMessage(playerid, COLOR_LIMEGREEN, string);
		}
        if (gPlayerInfo[killerid][pTeam]==gPlayerInfo[playerid][pTeam])
		{
            GivePlayerScoreSync(killerid,-1);
            SendClientMessage(killerid, COLOR_RED, "You lost 1 score for killing your own team mate!");
        }
        else
		{
		    gPlayerInfo[killerid][pKills]++;
 			KillingSpree[killerid]++;
			SessionKills[killerid]++;
			new vehid=GetPlayerVehicleID(killerid);
			//cut the rewards if he was in a powerful vehicle
			new money,score;
			if (!vehid)
			{
				money = random(3000)+2000;
				score=1;
			}
			else
			{
			    new model=GetVehicleModel(vehid);
			    switch (model)
			    {
			        case 425: money = random(500)+500; //hunter
			        case 520: money = random(1500)+500; //hydra
			        case 447: money = random(1500)+500; //seasparrow
			        case 432: { money = random(1500)+500; score=1; } //rhino
			        case 476: { money=random(10000); score=1; } //rustler
			        default: { money=random(3000)+2000; score=1; }
			    }
			}
			new wep=GetPlayerWeapon(killerid);
			switch(wep)
			{
			    case 16: GivePlayerWeaponEx(killerid,16,1);
				case 18: GivePlayerWeaponEx(killerid,18,1);
				case 26: GivePlayerWeaponEx(killerid,26,50);
				case 28: GivePlayerWeaponEx(killerid,28,200);
				case 32: GivePlayerWeaponEx(killerid,32,200);
				case 34: GivePlayerWeaponEx(killerid,34,30);
				case 35: GivePlayerWeaponEx(killerid,35,1);
				case 36: GivePlayerWeaponEx(killerid,36,1);
				case 39: GivePlayerWeaponEx(killerid,39,1);
				default: GivePlayerWeaponEx(killerid,wep,100);
			}
			if (score) String("You gained %d score, $%d and some ammo for killing enemy %s(%d)!",score,money,gPlayerInfo[playerid][pName],playerid);
			else String("You gained $%d and some ammo for killing enemy %s(%d)!",money,gPlayerInfo[playerid][pName],playerid);
			SendClientMessage(killerid, COLOR_LIMEGREEN, string);
			string = "\0";
			GivePlayerScoreSync(killerid,score);
 	   		GivePlayerMoneySync(killerid,money);
			switch(KillingSpree[killerid])
			{
				case 3: {
					String("[SPREE] %s(%d) is getting into the game with a killing spree of 3!",gPlayerInfo[killerid][pName],killerid);
					SendClientMessageToAll(COLOR_ORANGE, string);
				}
				case 5: {
					String("[SPREE] %s(%d) is on a killing spree! (made 5 kills without dying).",gPlayerInfo[killerid][pName],killerid);
					SendClientMessageToAll(COLOR_ORANGE, string);
					SendClientMessage(killerid, COLOR_YELLOW, "For the spree of 5 kills, you got 2 score and $2000 as a bonus!");
					GivePlayerMoneySync(killerid, 2000);
					GivePlayerScoreSync(killerid, 2);
				}
				case 10: {
					String("[SPREE] %s(%d) is on a rampage! (made 10 kills without dying).",gPlayerInfo[killerid][pName], killerid);
					SendClientMessageToAll(COLOR_ORANGE, string);
					SendClientMessage(killerid, COLOR_YELLOW, "For the spree of 10 kills, you got 5 score and $5000 as a bonus!");
					GivePlayerMoneySync(killerid, 5000);
					GivePlayerScoreSync(killerid, 5);
				}
				case 15: {
					String("[SPREE] %s(%d) is PWNING! (made 15 kills without dying).",gPlayerInfo[killerid][pName],killerid);
					SendClientMessageToAll(COLOR_ORANGE, string );
					SendClientMessage(killerid, COLOR_YELLOW, "For the spree of 15 kills, you got 7 score and $7000 as a bonus!");
					GivePlayerMoneySync(killerid, 7000);
					GivePlayerScoreSync(killerid,7);
				}
				case 25: {
					String("[SPREE] %s(%d) is DESTROYING! (made 20+ kills without dying).",gPlayerInfo[killerid][pName], killerid);
					SendClientMessageToAll(COLOR_ORANGE, string);
					SendClientMessage(killerid, COLOR_YELLOW, "You got +1 score and $5000 for the 20+ kills spree as a bonus!");
					SendClientMessage(killerid, COLOR_YELLOW, "Press C to get an RC-XD");
					GivePlayerScoreSync(killerid,1);
					GivePlayerMoneySync(killerid, 5000);
					SetPVarInt(killerid, "RC",1);
				}
				case 100: {
				    String("[SPREE] %s(%d) is GODLIKE! (made 100 kills without dying).",gPlayerInfo[killerid][pName], killerid);
				    SendClientMessageToAll(COLOR_ORANGE, string);
					SendClientMessage(killerid, COLOR_YELLOW, "You got +10 score,$10000 and a Nuclear Missle for the 100 kills spree as a bonus!");
					SendClientMessage(killerid, COLOR_YELLOW, "Press Y to activate your Nuclear Weaponary!");
					GivePlayerScoreSync(killerid, 10);
					GivePlayerMoneySync(killerid, 10000);
				}
			}
			if(KillingSpree[killerid] > 20)
			{
				SendClientMessage(killerid, COLOR_YELLOW, "You got +1 score and $5000 for the 20+ kills spree as a bonus!");
				GivePlayerScoreSync(killerid, 1);
				GivePlayerMoneySync(killerid, 5000);
			}
			if(SessionKills[killerid] == 50)
			{
				String("[SPREE] %s(%d) is OWNING - they have made 50 session kills!",gPlayerInfo[killerid][pName], killerid);
				SendClientMessageToAll(COLOR_ORANGE, string);
				SendClientMessage(killerid, COLOR_TEAL, "You got 5 score and $10000 as a bonus for 50 session kills!");
				GivePlayerMoneySync(killerid, 10000);
				GivePlayerScoreSync(killerid, 5);
			}
		}
		if (gPlayerInfo[playerid][pTeam]!=gPlayerInfo[killerid][pTeam] && IsPlayerInBase(playerid))
		{
			new KillerVeh=GetVehicleModel(GetPlayerVehicleID(killerid));
			if(IsPlayerInAnyVehicle(killerid) && KillerVeh == 425 || KillerVeh == 447 || KillerVeh == 520 || KillerVeh == 432)
			{
				DestroyVehicle(GetPlayerVehicleID(killerid));
				SendClientMessage(killerid, COLOR_RED, "Do NOT attack players in their home base with heavy vehicles! Read /hvrules!");
				SendClientMessage(killerid, COLOR_RED, "You have been automatically killed and deducted 2 kills and 2 score!");
				SetPlayerHealth(killerid, 0.0);
				GivePlayerScoreSync(killerid,-2);
				gPlayerInfo[playerid][pKills]++;
				String("%s has violated the heavy vehicle rules on you(/hvrules) by killing you in your base.",gPlayerInfo[killerid][pName]);
				SendClientMessage(playerid, COLOR_ORANGE, string);
				SendClientMessage(playerid, COLOR_ORANGE, "You have been deducted 1 death and given 1 kill for the violation.");
				gPlayerInfo[killerid][pKills]--;
				AutoWarn(killerid, "violating heavy vehicle rules(/hvrules) - base raping");
				print(string);
			}
		}
	} //EO invalid killerid check
	new vehid=GetPlayerVehicleID(playerid);
	//cut the rewards if he was in a powerful vehicle
	if (vehid && GetPVarInt(playerid, "AdminDuty") == 0)
	{
		new moneyloss,extra,mextra;
		new model=GetVehicleModel(vehid);
		switch (model)
		{
			case 425: { moneyloss = 1000; extra=2; mextra=8000; } //hunter
			case 520: { moneyloss = 1500; extra=2; mextra=8000; } //hydra
			case 447: { moneyloss = 500; extra=1; mextra=2000; } //seasparrow
			case 432: { moneyloss = 1000; extra=2; mextra=5000; } //rhino
		}
		if (moneyloss)
		{
			String("You have completely destroyed an expensive vehicle. $%d has been taken from your pay!", moneyloss);
			SendClientMessage(playerid, COLOR_RED, string);
			GivePlayerMoneySync(playerid, -moneyloss);
		}
		if (killerid!=INVALID_PLAYER_ID)
		{
			if (extra)
			{
				String("You received %d score and $%d for killing an enemy who was using a powerful vehicle.", extra,mextra);
				SendClientMessage(killerid, COLOR_LIMEGREEN, string);
				GivePlayerScoreSync(killerid, extra);
				GivePlayerMoneySync(killerid, mextra);
			}
		}
	}
	if (GetPVarType(playerid,"CappingZone")!=PLAYER_VARTYPE_NONE)
	{
	    SendClientMessage(playerid,COLOR_RED,"Failed to capture, you died!");
	    InterruptCap(playerid);
	}
	SendDeathMessage(killerid, playerid, reason);
	Update3DTextLabelText(gPlayerInfo[playerid][p3DText], COLOR_RED, "Died...");
 	RemovePlayerAttachedObject(playerid,0);
	UpdateRank(playerid);
    gPlayerInfo[playerid][pSpawned]=0;
    gPlayerInfo[playerid][pDeaths]++;
	if(GetPVarInt(playerid, "RCDeath") == 1) return 0;
	DeletePVar(playerid, "RC");
	DeletePVar(playerid, "ERC");
	SetPlayerColor(playerid, COLOR_LIGHTGRAY);
	if(InDM[playerid] == 1)
		SetPlayerTeam(playerid, NO_TEAM);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)