RandomSpawn question
#1

Hey, Im gonna explain this as good as i can...

Ok, I got this:
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>


#pragma tabsize 0
//=========colours
#define red 0xFF0000FF



new DMArea[MAX_PLAYERS];

new Float:RandomSpawns[4][3] = {
{2231.8542,-1162.1888,1029.7969}, 
{2240.6748,-1192.5139,1033.7969}, 
{2198.5537,-1193.8461,1029.7969}, 
{2189.0576,-1146.5973,1033.7969} 
};

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
		if (strcmp("/monster", cmdtext, true, 10) == 0)
		{
		DMArea[playerid] = 0;
		SetPlayerPos(playerid, 2791.3892,-2525.0396,13.6302);
		ResetPlayerWeapons(playerid);
		SetPlayerInterior(playerid,0);
		return 1;
		}
		if (strcmp("/nrg1", cmdtext, true, 10) == 0)
		{
    DMArea[playerid] = 0;
		SetPlayerPos(playerid, 1117.7536, -2036.9072, 77.7500);
		ResetPlayerWeapons(playerid);
  	SetPlayerInterior(playerid,0);
		return 1;
		}
		if (strcmp("/lsa", cmdtext, true, 10) == 0)
		{
    DMArea[playerid] = 0;
		SetPlayerPos(playerid, 1929.2640,-2669.5295,13.5532);
		ResetPlayerWeapons(playerid);
    SetPlayerInterior(playerid,0);
		return 1;
		}
		if (strcmp("/drag", cmdtext, true, 10) == 0)
		{
    DMArea[playerid] = 0;
		SetPlayerPos(playerid, -2680.9583,1263.1406,55.5628);
		ResetPlayerWeapons(playerid);
    SetPlayerInterior(playerid,0);
		return 1;
		}
		if (strcmp("/kill", cmdtext, true, 10) == 0)
		{
		if(DMArea[playerid] == 1) return SendClientMessage(playerid,red,"Cannot use this command here");
		SetPlayerHealth(playerid, 0);
		return 1;
		}
		if (strcmp("/nrg", cmdtext, true, 10) == 0)
		{
    DMArea[playerid] = 0;
		SetPlayerPos(playerid, 2838.3564,-2356.4373,42.7344);
		ResetPlayerWeapons(playerid);
    SetPlayerInterior(playerid,0);
		return 1;
		}
		if (strcmp("/sfa", cmdtext, true, 10) == 0)
		{
    DMArea[playerid] = 0;
		SetPlayerPos(playerid, -1380.9598,-255.8481,14.1440);
		ResetPlayerWeapons(playerid);
    SetPlayerInterior(playerid,0);
		return 1;
		}
		if (strcmp("/para", cmdtext, true, 10) == 0)
		{
		GivePlayerWeapon(playerid, 46,1);
		return 1;
		}
		if (strcmp("/cmds", cmdtext, true, 10) == 0)
		{
		SendClientMessage(playerid, 0xAA3333AA, "/heal, /armour, /kill, /para, /nos, and /teles");
		return 1;
		}
		if (strcmp("/teles", cmdtext, true, 10) == 0)
		{
		SendClientMessage(playerid, 0xAA3333AA, "/lsa, /sfa, /drag, /monster, /nrg, and /nrg1");
		return 1;
		}
		if(strcmp(cmdtext, "/fix", true) == 0){
		{
		RepairVehicle(GetPlayerVehicleID(playerid));
  	return 1;
		}
		}
		if(strcmp(cmdtext, "/flip", true) == 0)
  	{
    new currentveh,Float:ang;
    currentveh = GetPlayerVehicleID(playerid);
    GetVehicleZAngle(currentveh,ang);
		SetVehicleZAngle(currentveh, ang+0.5);
		SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been flipped.");
    return 1;
		}
//========================/heal and /armour=====================================
	if(strcmp(cmdtext,"/heal",true)==0)
	{
	if(DMArea[playerid] == 1) return SendClientMessage(playerid,red,"Cannot use this command here!");
	SetPlayerHealth(playerid,100);
	return 1;
	}
	if(strcmp(cmdtext,"/armour",true)==0)
	{
  if(DMArea[playerid] == 1) return SendClientMessage(playerid,red,"Cannot use this command here!");
	SetPlayerArmour(playerid,100);
	return 1;
	}
//===================================/dm1=======================================
	if(strcmp(cmdtext,"/dm1",true)==0)
	{
	DMArea[playerid] = 1;
	new rand = random(sizeof(RandomSpawns));
	SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]); 
  SetPlayerInterior(playerid,15); 
  GameTextForPlayer(playerid,"Welcome to Jefferson Motel Dm Area",4000,6); 
  ResetPlayerWeapons(playerid); 
  GivePlayerWeapon(playerid,31,50000); 
  GivePlayerWeapon(playerid,4,50000); 
  GivePlayerWeapon(playerid,32,50000); 
  GivePlayerWeapon(playerid,34,50000); 
  GivePlayerWeapon(playerid,42,50000); 
  GivePlayerWeapon(playerid,27,50000); 
  GivePlayerWeapon(playerid,24,50000); 
	GivePlayerWeapon(playerid,18,50000);
 	return 1;
	}
//======================================/minigun================================
	if(strcmp(cmdtext,"/minigun",true)==0)
	{
	DMArea[playerid] = 1;
	SetPlayerPos(playerid,1299.14,-794.77,1084.00); 
  SetPlayerInterior(playerid,5); 
  GameTextForPlayer(playerid,"Welcome to Madd dog's Dm Area",4000,6); 
  ResetPlayerWeapons(playerid); 
  GivePlayerWeapon(playerid,38,50000);
  return 1;
	}
//=============================/deagle==========================================
	if(strcmp(cmdtext,"/deagle",true)==0)
	{
	DMArea[playerid] = 1;
	SetPlayerPos(playerid,2016.2699,1017.7790,996.8750); 
  SetPlayerInterior(playerid,10); 
  GameTextForPlayer(playerid,"Welcome to 4 Dragons Casino Dm Area",4000,6); 
  ResetPlayerWeapons(playerid); 
  GivePlayerWeapon(playerid,24,50000);
  return 1;
	}
//=======================================/dm2===================================
	if(strcmp(cmdtext,"/dm2",true)==0)
	{
	DMArea[playerid] = 1;
	SetPlayerPos(playerid,246.40,110.84,1003.22); 
  SetPlayerInterior(playerid,10); 
  GameTextForPlayer(playerid,"Welcome to Police Dm Area",4000,6); 
  ResetPlayerWeapons(playerid); 
  GivePlayerWeapon(playerid,4,50000);
  GivePlayerWeapon(playerid,9,50000);
  GivePlayerWeapon(playerid,16,50000);
  GivePlayerWeapon(playerid,24,50000);
  GivePlayerWeapon(playerid,29,50000);
  GivePlayerWeapon(playerid,31,50000);
  GivePlayerWeapon(playerid,45,50000);
  GivePlayerWeapon(playerid,42,50000);
  GivePlayerWeapon(playerid,26,50000);
  return 1;
	}
	return SendClientMessage(playerid,red,"Unknown Command! Use /cmds to check the right commands");
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
I doesnt get any errors while compiling and everything works just fine. But I need RandomSpawn on /dm2 too, not only on /dm1... Any one knows how to fix this??
Reply
#2

Nobody can answer??
Reply
#3

new rand = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);

maybe?
Reply
#4

Ok, I figured it out mah self ^^
Reply
#5

alrighty then good luck
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)