SA-MP Forums Archive
[HELP]A DM with random spawns - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]A DM with random spawns (/showthread.php?tid=71769)



[HELP]A DM with random spawns - 17badboy17 - 03.04.2009

I need help creating a dm with random respawns on death
I made this, but it doesn't work
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new IsPlayerInDM[MAX_PLAYERS];


	if ((strcmp("/dm1", cmdtext, true, 10) == 0)&&(IsPlayerInDM[playerid] == 0))
	{
		new pName[MAX_PLAYER_NAME];
    new string[256];
		IsPlayerInDM[playerid] = 1;
		GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s has entered dm1. Type /dm1 to pwn him", pName);
    SendClientMessageToAll(0xFFFFAEFF, string);
		SetPlayerPos(playerid, -379.5638,2222.6265,42.0938);
		SetPlayerArmour(playerid, 100.00);
		GivePlayerWeapon(playerid, 6, 500);
		GivePlayerWeapon(playerid, 26, 500);
		GivePlayerWeapon(playerid, 32, 500);
		GivePlayerWeapon(playerid, 41, 500);
		SetPlayerWorldBounds(playerid, -331.0740,-472.8714,2282.5764, 2141.8994);
		return 1;
	}
{
public OnPlayerSpawn(playerid)
new IsPlayerInDM[MAX_PLAYERS];
if (IsPlayerInDM[playerid] == 1)
	{
		new c = random(2); //random respawn
  		if (c == 0){
  		SetPlayerPos(playerid,-366.4124,2268.1926,42.3083);}
  		else if (c == 1){
  		SetPlayerPos(playerid, -336.1055,2198.8230,45.5047);}
  		else if (c == 2){
  		SetPlayerPos(playerid, -423.1209,2190.5198,42.0999);}
  		else {
  		SetPlayerPos(playerid, -447.9061,2265.9319,45.8330);}
	}
}



Re: [HELP]A DM with random spawns - Klutty - 03.04.2009

pawn Код:
if ((strcmp("/dm1", cmdtext, true, 10) == 0)&&(IsPlayerInDM[playerid] == 0))
    {
        new pName[MAX_PLAYER_NAME];
    new string[256];
        IsPlayerInDM[playerid] = 1;
        GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s has entered dm1. Type /dm1 to pwn him", pName);
    SendClientMessageToAll(0xFFFFAEFF, string);
    const MAX_POSITIONS = 3;
static Float:Positions[MAX_POSITIONS][4] =
{
    {0.0, 0.0, 0.0, 0.0}, // pos 1
    {0.0, 0.0, 0.0, 0.0}, // pos 2
    {0.0, 0.0, 0.0, 0.0} // pos 3
}, bool:taken[MAX_POSITIONS];
new freePos;
for(; freePos < MAX_POSITIONS; freePos++)
    if(!taken[freePos]) break;
if(freePos == MAX_POSITIONS) return; //no free positions left
SetPlayerPos(playerid, Positions[freePos][0], Positions[freePos][1], Positions[freePos][2]);
SetPlayerFacingAngle(playerid, Positions[freePos][3]);
taken[freePos] = true;
Use that, should work.


Re: [HELP]A DM with random spawns - 17badboy17 - 03.04.2009

Could you explain the code please. I just started.
Also, I want a code which would respawn a player in dm1, when he died, this just randomly spawns him in dm1, i think.

And it also threw out some errors
Код:
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(12) : error 001: expected token: ";", but found "if"
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(12) : warning 217: loose indentation
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(21) : warning 217: loose indentation
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(30) : warning 209: function "OnPlayerCommandText" should return a value
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(34) : warning 217: loose indentation
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(34) : error 078: function uses both "return" and "return <value>"
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(36) : warning 217: loose indentation
C:\Documents and Settings\Tadej\Desktop\samp server\samp02Xserver.win32\filterscripts\Untitled.pwn(36) : error 078: function uses both "return" and "return <value>"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: [HELP]A DM with random spawns - Klutty - 03.04.2009

pawn Код:
if ((strcmp("/dm1", cmdtext, true, 10) == 0)&&(IsPlayerInDM[playerid] == 0))
    {
        new pName[MAX_PLAYER_NAME];
    new string[256];
        IsPlayerInDM[playerid] = 1;
        GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s has entered dm1. Type /dm1 to pwn him", pName);
    SendClientMessageToAll(0xFFFFAEFF, string);
    const MAX_POSITIONS = 3;
static Float:Positions[MAX_POSITIONS][4] =
{
    {0.0, 0.0, 0.0, 0.0}, // pos 1
    {0.0, 0.0, 0.0, 0.0}, // pos 2
    {0.0, 0.0, 0.0, 0.0} // pos 3
}, bool:taken[MAX_POSITIONS];
new freePos;
for(; freePos < MAX_POSITIONS; freePos++)
    if(!taken[freePos]) break;
if(freePos == MAX_POSITIONS) return 1; //no free positions left
SetPlayerPos(playerid, Positions[freePos][0], Positions[freePos][1], Positions[freePos][2]);
SetPlayerFacingAngle(playerid, Positions[freePos][3]);
taken[freePos] = true;
There, but you must fix the intendation, do you have teamviewer? If so, I can help you ( by controlling your pc and editing the script from my pc)