SA-MP Forums Archive
OnPlayerSpawn - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerSpawn (/showthread.php?tid=606031)



OnPlayerSpawn - Micko123 - 28.04.2016

Hey guys. I recently made DM zone and commands and everything but now when player dies he spawns in that DM zone (and that is what i want) but he spawns with no guns and he can type again /dm (and i don't want that). How can i fix this. Here is my script of that
Код:
if(PlayerJoinedDMZone[playerid] == 1)
    {
        new randomcoords = random(sizeof(DMSpawn));
        SPP(playerid, DMSpawn[randomcoords][0], DMSpawn[randomcoords][1], DMSpawn[randomcoords][2]);
    }
    return 1;
}

CMD:dm(playerid, params[])
{
    PlayerJoinedDMZone[playerid] = 1;
    new randomcoords = random(sizeof(DMSpawn));
    SPP(playerid, DMSpawn[randomcoords][0],
				  DMSpawn[randomcoords][1],
	              DMSpawn[randomcoords][2]);
	GivePlayerWeapon(playerid, 26, 100);
	GivePlayerWeapon(playerid, 22, 100);
	GivePlayerWeapon(playerid, 25, 100);
	GivePlayerWeapon(playerid, 28, 500);
	GivePlayerWeapon(playerid, 30, 100);
	GivePlayerWeapon(playerid, 33, 50);
	SetPlayerArmour(playerid, 100);
	SPH(playerid, 100);
	return 1;
}

CMD:napustidm(playerid, params[])
{
	PlayerJoinedDMZone[playerid] = 0;
 	SCM(playerid, 0xF81414, "Napustili ste DM zonu");
 	SPP(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}



Re: OnPlayerSpawn - Micko123 - 28.04.2016

i've putted
Код:
if(PlayerJoinedDMZone[playerid] == 1)
    {
        new randomcoords = random(sizeof(DMSpawn));
        SPP(playerid, DMSpawn[randomcoords][0], DMSpawn[randomcoords][1], DMSpawn[randomcoords][2]);
    }
    return 1;
}
under OnPlayerSpawn


Re: OnPlayerSpawn - Ritzy2K - 28.04.2016

Okay, so player spawns at DM zone after dying? And that's how you want it to work, but player doesnt get the weps? Well, just check your variable if its equal to 1 (the DM zone one) give him the guns.

Edit: I saw your reply, I'm from phone chances are this code might miss some braces or whatever.

Код:
if(PlayerJoinedDMZone[playerid] == 1)
    {
        new randomcoords = random(sizeof(DMSpawn));
        SPP(playerid, DMSpawn[randomcoords][0], DMSpawn[randomcoords][1], DMSpawn[randomcoords][2]);
GivePlayerWeapon(playerid, 26, 100);
	GivePlayerWeapon(playerid, 22, 100);
	GivePlayerWeapon(playerid, 25, 100);
	GivePlayerWeapon(playerid, 28, 500);
	GivePlayerWeapon(playerid, 30, 100);
	GivePlayerWeapon(playerid, 33, 50);
	SetPlayerArmour(playerid, 100);
	SPH(playerid, 100);
    }
    return 1;
}



Re: OnPlayerSpawn - Micko123 - 28.04.2016

But there is another problem. After he spawn in DM zone after dying server doesn't recognize him as player in DM zone and he can type /dm again. Maybe there is something wrong in /dm code
Код:
CMD:dm(playerid, params[])
{
    PlayerJoinedDMZone[playerid] = 1;
    new randomcoords = random(sizeof(DMSpawn));
    SPP(playerid, DMSpawn[randomcoords][0],
				  DMSpawn[randomcoords][1],
	              DMSpawn[randomcoords][2]);
	GivePlayerWeapon(playerid, 26, 100);
	GivePlayerWeapon(playerid, 22, 100);
	GivePlayerWeapon(playerid, 25, 100);
	GivePlayerWeapon(playerid, 28, 500);
	GivePlayerWeapon(playerid, 30, 100);
	GivePlayerWeapon(playerid, 33, 50);
	SetPlayerArmour(playerid, 100);
	SPH(playerid, 100);
	SCM(playerid, 0xF81414, "Dobrodosli u DM zonu. Srecno :)");
	return 1;
}



Re: OnPlayerSpawn - Ritzy2K - 28.04.2016

Do you change the variable value OnPlayerDeath?


Re: OnPlayerSpawn - Micko123 - 28.04.2016

Should it go like this?/
Код:
	if(PlayerJoinedDMZone[playerid] == 1)
	{
	    PlayerJoinedDMZone[playerid] = 1;
	}
this goes under OnPlayerDeath


Re: OnPlayerSpawn - Ritzy2K - 28.04.2016

I'm not sure what are you trying to say though. You're checking if variable's value is 1, and then setting it back to 1. Lol


Re: OnPlayerSpawn - iKevin - 28.04.2016

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Should it go like this?/
Код:
	if(PlayerJoinedDMZone[playerid] == 1)
	{
	    PlayerJoinedDMZone[playerid] = 1;
	}
this goes under OnPlayerDeath
The OnPlayerDeath, shall look like this
Код:
 	if(PlayerJoinedDMZone[playerid] == 1)
	{
	    PlayerJoinedDMZone[playerid] = 0;
	}



Re: OnPlayerSpawn - Micko123 - 29.04.2016

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
The OnPlayerDeath, shall look like this
Код:
 	if(PlayerJoinedDMZone[playerid] == 1)
	{
	    PlayerJoinedDMZone[playerid] = 0;
	}
No no. You don't understand. I want playe when he dies in DM zone to stay in DM zone and to respawn there. So my code works perfectly But thank you anyway


Re: OnPlayerSpawn - iKevin - 29.04.2016

Quote:
Originally Posted by Micko123
Посмотреть сообщение
No no. You don't understand. I want playe when he dies in DM zone to stay in DM zone and to respawn there. So my code works perfectly But thank you anyway
Oh okay.