SA-MP Forums Archive
[Solved] id 0 issue - 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: [Solved] id 0 issue (/showthread.php?tid=107274)



[Solved] id 0 issue - troy52192 - 09.11.2009

im having an issue with trying to spawn at my deathpoint. it works fine and correctly but its going to id 0s spawn point. how can i fix this to where it to spawn to my own position?

Here is my Code:

Код:
#include <a_samp>

#define deathpoint1 (324)

new IsPlayerDead[MAX_PLAYERS];
new Float:xpos1, Float:ypos1, Float:zpos1;
new Float:Anglepos1;
new mycarid;
new Float:vzrot;

public OnPlayerDeath(playerid, killerid, reason)
{
	IsPlayerDead[playerid]=1;
	if(IsPlayerDead[playerid]==1)
	{
	GetPlayerFacingAngle(playerid, Anglepos1);
	GetPlayerPos(playerid,xpos1,ypos1,zpos1);
	mycarid=GetPlayerVehicleID(playerid);
	GetVehiclePos(playerid,xpos1,ypos1,zpos1);
	GetVehicleZAngle(mycarid, vzrot);
 	return 1;
  }
  	return 1;
  }
  
public OnPlayerSpawn(playerid)
{
  	if(IsPlayerDead[playerid]==1)
	{
	ShowPlayerDialog(playerid, deathpoint1, DIALOG_STYLE_MSGBOX, "Question", "Do you want to Spawn back to where you died?", "yes", "no");
	}
	return 1;
  }
  
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  	if (dialogid == deathpoint1)
  {
    if (response == 1)
    {
    if(IsPlayerDead[playerid]==1)
		{
		SetPlayerFacingAngle( playerid, Anglepos1);
 		SetPlayerPos(playerid, xpos1, ypos1, zpos1);
 		SetVehiclePos(mycarid,xpos1,ypos1,zpos1);
  		SetVehicleZAngle(mycarid, vzrot);
  		PutPlayerInVehicle(playerid, mycarid, 0);
  		SendClientMessage(playerid, 0xFFFFFFFF, "You have Teleported Where You Died");
    }}
    else
    {
		SendClientMessage(playerid, 0xFFFFFFFF, "You Cancelled");
    }
    return 1;
  }
  return 1;
}



Re: id 0 issue - MenaceX^ - 09.11.2009

Use an array (MAX_PLAYERS for example.)


Re: id 0 issue - troy52192 - 09.11.2009

can you show me an example for my concept?


Re: id 0 issue - MenaceX^ - 09.11.2009

pawn Код:
new
  Float:xpos1[MAX_PLAYERS],
  Float:ypos1[MAX_PLAYERS],
  Float:zpos1[MAX_PLAYERS];



Re: id 0 issue - troy52192 - 09.11.2009

ok what i did was got rid of the vehicle part and it works fine but before i was teleporting to the one of the npc's location which is id 0


Re: id 0 issue - troy52192 - 09.11.2009

also can u help me with another problem of mine?
ok here it is: i have timers for npc 4 rc tanks right? what the timers do is creates explosions in front my 4 rc tanks. but the explosions r only creating for the ID 0 which is my barron. any solution?
Here is my code:

oh btw the 2 Bandits r tanks as well
Код:
#include <a_samp>
#include <a_npc>
#define FILTERSCRIPT
new Barronr1;
new Barronr2;
new Banditr1;
new Banditr2;
new Goblinr1;
new Goblinr2;
new Raiderr1;
new Raiderr2;
new Tankr1;
new Tankr2;
public OnFilterScriptInit(){
	print(" _______________________________");
	print("| LOADING...          |");
	print("| RC BOTS           |");
	print("| By Troy Version 1.00     |");
	print("|_______________________________|");
	ConnectNPC("Barrond1","Barron1");
	ConnectNPC("Barrond2","Barron2");
	ConnectNPC("Banditd1","Bandit1");
	ConnectNPC("Banditd2","Bandit2");
	ConnectNPC("Goblind1","Goblin1");
	ConnectNPC("Goblind2","Goblin2");
	ConnectNPC("Raiderd1","Raider1");
	ConnectNPC("Raiderd2","Raider2");
	ConnectNPC("Tankd1","Tank1");
	ConnectNPC("Tankd2","Tank2");
	Barronr1 = CreateVehicle(464,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Barronr2 = CreateVehicle(464,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Banditr1 = CreateVehicle(564,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Banditr2 = CreateVehicle(564,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Goblinr1 = CreateVehicle(501,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Goblinr2 = CreateVehicle(501,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Raiderr1 = CreateVehicle(465,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Raiderr2 = CreateVehicle(465,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Tankr1 = CreateVehicle(564,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	Tankr2 = CreateVehicle(564,-1004.2155,994.8294,1411.7723,205.4225,1,1,1);
	LinkVehicleToInterior(Barronr1, 10);
	LinkVehicleToInterior(Barronr2, 10);
	LinkVehicleToInterior(Banditr1, 10);
	LinkVehicleToInterior(Banditr2, 10);
	LinkVehicleToInterior(Goblinr1, 10);
	LinkVehicleToInterior(Goblinr2, 10);
	LinkVehicleToInterior(Raiderr1, 10);
	LinkVehicleToInterior(Raiderr2, 10);
	LinkVehicleToInterior(Tankr1, 10);
	LinkVehicleToInterior(Tankr2, 10);
	}
	public OnPlayerSpawn(playerid)
	{
	if(IsPlayerNPC(playerid))
  {
	new npcname[MAX_PLAYER_NAME];
 	GetPlayerName(playerid, npcname, sizeof(npcname));

	if(!strcmp(npcname,"Barrond1",true)) {
 	PutPlayerInVehicle(playerid, Barronr1, 0);
 	LinkVehicleToInterior(Barronr1, 10);
 	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
  return 1;
  }

 	if(!strcmp(npcname,"Barrond2",true)) {
 	PutPlayerInVehicle(playerid, Barronr2, 0);
	LinkVehicleToInterior(Barronr2, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
  return 1;
  }

 	if(!strcmp(npcname,"Banditd1",true)) {
 	PutPlayerInVehicle(playerid, Banditr1, 0);
 	SetPlayerColor(playerid,0xFF000050);
 	LinkVehicleToInterior(Banditr1, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
	SetTimer("exploding1",5000,true);
 	return 1;
  }

 	if(!strcmp(npcname,"Banditd2",true)) {
 	PutPlayerInVehicle(playerid, Banditr2, 0);
 	LinkVehicleToInterior(Banditr2, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
	SetTimer("exploding2",5000,true);
 	return 1;
  }

 	if(!strcmp(npcname,"Goblind1",true)) {
 	PutPlayerInVehicle(playerid, Goblinr1, 0);
 	LinkVehicleToInterior(Goblinr1, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
  return 1;
  }

 	if(!strcmp(npcname,"Goblind2",true)) {
 	PutPlayerInVehicle(playerid, Goblinr2, 0);
	LinkVehicleToInterior(Goblinr2, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
  return 1;
  }

 	if(!strcmp(npcname,"Raiderd1",true)) {
 	PutPlayerInVehicle(playerid, Raiderr1, 0);
 	LinkVehicleToInterior(Raiderr1, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
  return 1;
  }

 	if(!strcmp(npcname,"Raiderd2",true)) {
 	PutPlayerInVehicle(playerid, Raiderr2, 0);
	LinkVehicleToInterior(Raiderr2, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
  return 1;
  }

	if(!strcmp(npcname,"Tankd1",true)) {
 	PutPlayerInVehicle(playerid, Tankr1, 0);
 	LinkVehicleToInterior(Tankr1, 10);
 	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
	SetTimer("exploding3",5000,true);
 	return 1;
  }

 	if(!strcmp(npcname,"Tankd2",true)) {
 	PutPlayerInVehicle(playerid, Tankr2, 0);
	LinkVehicleToInterior(Tankr1, 10);
	SetPlayerColor(playerid,0xFF000050);
  SetPlayerSkin(playerid,287);
	SetTimer("exploding4",5000,true);
 	return 1;
  }
  return 1;
  }
	return 1;
	}
forward exploding1(playerid);
public exploding1(playerid){
	new Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:az;
	GetPlayerPos(playerid,x,y,z);
	GetVehicleZAngle(GetPlayerVehicleID(playerid), az);
	x2 = x + (15 * floatsin(-az+5, degrees));
	y2 = y + (30 * floatcos(-az+5, degrees));
	CreateExplosion(x2,y2,z,3,4.0);
	return 1;}
forward exploding2(playerid);
public exploding2(playerid){
	new Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:az;
	GetPlayerPos(playerid,x,y,z);
	GetVehicleZAngle(GetPlayerVehicleID(playerid), az);
	x2 = x + (15 * floatsin(-az+5, degrees));
	y2 = y + (30 * floatcos(-az+5, degrees));
	CreateExplosion(x2,y2,z,3,4.0);
	return 1;}
	forward exploding3(playerid);
public exploding3(playerid){
	new Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:az;
	GetPlayerPos(playerid,x,y,z);
	GetVehicleZAngle(GetPlayerVehicleID(playerid), az);
	x2 = x + (15 * floatsin(-az+5, degrees));
	y2 = y + (30 * floatcos(-az+5, degrees));
	CreateExplosion(x2,y2,z,3,4.0);
	return 1;}
	forward exploding4(playerid);
public exploding4(playerid){
	new Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:az;
	GetPlayerPos(playerid,x,y,z);
	GetVehicleZAngle(GetPlayerVehicleID(playerid), az);
	x2 = x + (15 * floatsin(-az+5, degrees));
	y2 = y + (30 * floatcos(-az+5, degrees));
	CreateExplosion(x2,y2,z,3,4.0);
	return 1;}



Re: id 0 issue - Daren_Jacobson - 09.11.2009

pawn Код:
IsPlayerDead[playerid]=1;
if(IsPlayerDead[playerid]==1)
that has to be the single most stupid thing i have ever seen.


Re: id 0 issue - retart441 - 09.11.2009

On player death should make the variable.

Then take all that under the if statment and move it to onplayerspawn.
problem fixed.




Re: id 0 issue - Djiango - 09.11.2009

Quote:
Originally Posted by troy52192
also can u help me with another problem of mine?
ok here it is: i have timers for npc 4 rc tanks right? what the timers do is creates explosions in front my 4 rc tanks. but the explosions r only creating for the ID 0 which is my barron. any solution?
Here is my code:

oh btw the 2 Bandits r tanks as well
Use SetTimerEx instead of SetTimer!