SA-MP Forums Archive
public OnPlayerSpawn(playerid) dosen`t work - 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: public OnPlayerSpawn(playerid) dosen`t work (/showthread.php?tid=655299)



public OnPlayerSpawn(playerid) dosen`t work - 3417512908 - 18.06.2018

I updata my Linux server to 0.3DL.
All models are normal work.But OnPlayerSpawn.It dosen`t work.When I spawn just like no anything happen
Where is wrong?


Re: public OnPlayerSpawn(playerid) dosen`t work - 3417512908 - 18.06.2018

My gamemode`s public OnPlayerSpawn(playerid)
Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pLogin]==0)
	{
	SetTimerEx("KICK", 500, false, "i", playerid);
	return 1;
	}
    if(PlayerInfo[playerid][pBan]==1)
    {
    Dialog(playerid,999,DIALOG_STYLE_MSGBOX,"{FF0000}警告","{FF0000}你已被封号\n如有问题,带上你的游戏昵称向我们报告\n3417512908@qq.com\nmailofblume@gmail","Okay","");
    SetTimerEx("KICK", 500, false, "i", playerid);
    return 1;
    }
    if(GetPVarInt(playerid,"IsDeath")==1)
	{
	SetPVarInt(playerid,"IsDeath",0);//玩家重生了,他没有假死
	}
	SendClientMessage(playerid,-1,"{008080}================================================================");
    SendClientMessage(playerid,-1,"{FF0000}我的菜单:{ffffff}/wdcd   {FF8000}帮助:{ffffff}/help   {FFFF00}更换游戏模式:{ffffff}按'N'(或/m)   {00FF00}动作:{ffffff}步行状态按'H'");
    SendClientMessage(playerid,-1,"{008080}================================================================");
    Money(playerid);
	SetPlayerFightingStyle(playerid,PlayerInfo[playerid][pFightStyle]);
	SetPlayerWantedLevel(playerid, 0);
	PlayerPlaySound(playerid, 1185+1, 0.0, 0.0, 0.0);
	PlayerTextDrawHide(playerid, Wasted0[playerid]);
	PlayerTextDrawHide(playerid, Wasted1[playerid]);
	PlayerTextDrawHide(playerid, Wasted2[playerid]);
	PlayerTextDrawHide(playerid, Wasted3[playerid]);
	PlayerTextDrawHide(playerid, Wasted4[playerid]);
	PlayerTextDrawHide(playerid, Wasted5[playerid]);
	PlayerTextDrawHide(playerid, Wasted6[playerid]);
	new string[128];
    format(string, sizeof(string), "TIME:%d",GetPlayerScore(playerid));
    PlayerTextDrawSetString(playerid,welcomeText[playerid],string);
    PlayerTextDrawHide(playerid, welcomeText[playerid]);
    PlayerTextDrawShow(playerid, welcomeText[playerid]);
	
	
	
	
	
	if(PlayerInfo[playerid][pCZ]>0)
	{
	new str[256];
	format(str, sizeof(str), "{FFFF00}你充值了 %d RMB,快去用户中心领取吧! /user",PlayerInfo[playerid][pCZ]);
    SendClientMessage(playerid,-1,str);
	}
	
	
	if(PlayerInfo[playerid][pHouseBuyed]>0)
	{
	new ck = PlayerInfo[playerid][pWDCK];
	new buyed = PlayerInfo[playerid][pHouseBuyed];
	new str[256];
	new all = ck+buyed;
    PlayerInfo[playerid][pWDCK]=PlayerInfo[playerid][pWDCK]+PlayerInfo[playerid][pHouseBuyed];
    PlayerInfo[playerid][pHouseBuyed]=0;
    Money(playerid);
    SendClientMessage(playerid,-1,"{0080FF}================================================================");
    SendClientMessage(playerid,-1,"{00FF00}房子离线收款信息:");
    SendClientMessage(playerid,-1,"{00FF00}在你离线的时候,某人购买了你的房子,支付了你设置的价格");
    SendClientMessage(playerid,-1,"{00FF00}现在金钱已打入你仓库:");
    format(str, sizeof(str), "{FFFF00}仓库金额 %d + 房子价格 %d = 现仓库金额 %d",ck,buyed,all);
    SendClientMessage(playerid,-1,str);
    SendClientMessage(playerid,-1,"{0080FF}================================================================");
	}
	
	
	
	
	

	
	
	
	
	if(GameMode[playerid]>=1)
	{
	if(GameMode[playerid]==1)//反恐部队
	{
	ResetPlayerWeapons(playerid);
	SetPlayerInterior(playerid,0);
	SetPlayerPos(playerid,202.3962,1922.1144,17.6406);
	SetPlayerSkin(playerid,285);
	GivePlayerWeapon(playerid,4,1);
	GivePlayerWeapon(playerid,29,999);
	GivePlayerWeapon(playerid,31,999);
	GivePlayerWeapon(playerid,16,2);
	SetPlayerHealth(playerid,100);
    SetPlayerArmour(playerid,100);
	return 1;
	}
	if(GameMode[playerid]==2)//恐怖分子
	{
	GodMode[playerid] = 0;
	ResetPlayerWeapons(playerid);
	SetPlayerVirtualWorld(playerid, 901);
	SetPlayerInterior(playerid,0);
	SetPlayerPos(playerid,82.0927,2234.1675,70.1799);
	SetPlayerSkin(playerid,206);
	GivePlayerWeapon(playerid,9,1);
	GivePlayerWeapon(playerid,35,5);
	GivePlayerWeapon(playerid,27,999);
	GivePlayerWeapon(playerid,28,999);
	SetPlayerHealth(playerid,100);
    SetPlayerArmour(playerid,100);
	return 1;
	}
	if(GameMode[playerid]==3)//沙鹰死斗
	{
	new Random = random(sizeof(DM));
	SetPlayerPos(playerid, DM[Random][0], DM[Random][1], DM[Random][2]);
    SetPlayerFacingAngle(playerid, DM[Random][3]);
    SetPlayerInterior(playerid,16);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid,24,9999);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    SetPlayerHealth(playerid,100);
    SetPlayerArmour(playerid,100);
    return 1;
	}
	if(GameMode[playerid]==4)//一击必杀
	{
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	SetPlayerInterior(playerid,18);
    new Random = random(sizeof(ONE));
    SetPlayerPos(playerid, ONE[Random][0], ONE[Random][1], ONE[Random][2]);
    SetPlayerFacingAngle(playerid, ONE[Random][3]);
    ResetPlayerWeapons(playerid);
    SetPlayerHealth(playerid,100);
    GivePlayerWeapon(playerid,8,9999);
    return 1;
	}
	if(GameMode[playerid]==5)//加特林死斗
	{
	           SetPlayerInterior(playerid,5);
               new Random = random(sizeof(MG));
               SetPlayerPos(playerid, MG[Random][0], MG[Random][1], MG[Random][2]);
               SetPlayerFacingAngle(playerid, MG[Random][3]);
               ResetPlayerWeapons(playerid);
               GivePlayerWeapon(playerid,38,9999);
			   SetPlayerHealth(playerid,100);
			   SetPlayerArmour(playerid,100);
               GameMode[playerid]=5;
               SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
               return 1;
	}
	if(GameMode[playerid]==6)//葛洛夫家族
	{
	           ResetPlayerWeapons(playerid);
           	   SetPlayerInterior(playerid,0);
	           SetPlayerPos(playerid,2512.3596,-1674.6843,13.5509);
	           SetPlayerSkin(playerid,107);
	           GivePlayerWeapon(playerid,30,999);
	           GivePlayerWeapon(playerid,25,999);
	           SetPlayerHealth(playerid,100);
			   SetPlayerArmour(playerid,100);
			   return 1;
	}
    if(GameMode[playerid]==7)//巴拉斯家族
	{
	           ResetPlayerWeapons(playerid);
	           SetPlayerInterior(playerid,0);
	           SetPlayerPos(playerid,2366.5505,-1664.4867,13.5469);
	           SetPlayerSkin(playerid,104);
	           GivePlayerWeapon(playerid,29,999);
	           GivePlayerWeapon(playerid,33,999);
	           SetPlayerHealth(playerid,100);
			   SetPlayerArmour(playerid,100);
			   return 1;
	
	}
	if(GameMode[playerid]==8)//遨游太空
	{
               SetPlayerInterior(playerid,1);
               new Random = random(sizeof(AYTK));
	           SetPlayerPos(playerid, AYTK[Random][0], AYTK[Random][1], AYTK[Random][2]);
               SetPlayerFacingAngle(playerid, AYTK[Random][3]);
               ResetPlayerWeapons(playerid);
			   SetPlayerHealth(playerid,100);
			   SetPlayerArmour(playerid,100);
               SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
               GivePlayerWeapon(playerid,28,9999);
               SetPlayerWeather(playerid, 91);
               SetPlayerTime(playerid, 9,0);
               
               return 1;
	}
	if(GameMode[playerid]==9)//电锯惊魂
	{
	           new Random = random(sizeof(DJJH2));
	           SetPlayerPos(playerid, DJJH2[Random][0], DJJH2[Random][1], DJJH2[Random][2]);
	           SetPlayerInterior(playerid,0);
			   SetPlayerHealth(playerid,100);
        	   SetPlayerTime(playerid,0,0);
               ChangeDJJHTeam(playerid);
               Dialog(playerid,999,DIALOG_STYLE_MSGBOX,"电锯惊魂","游戏说明: 分僵尸和人类,僵尸拥有电锯,玩家只有一把小手枪\n但是每分钟会随机换角色~","Okay","");
               return 1;
	}
	if(GameMode[playerid]==10)//不正常的DM
	{

               SetPlayerInterior(playerid,0);
               new Random = random(sizeof(BZC));
               SetPlayerPos(playerid, BZC[Random][0], BZC[Random][1], BZC[Random][2]);
               SetPlayerVirtualWorld(playerid,908);
               ResetPlayerWeapons(playerid);
			   SetPlayerHealth(playerid,100);
			   SetPlayerArmour(playerid,100);
               SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
               GivePlayerWeapon(playerid,23,9999);
               GivePlayerWeapon(playerid,25,9999);
               Dialog(playerid,999,DIALOG_STYLE_MSGBOX,"不正常的DM","游戏说明:你手上有'传送枪'和一把'爆炸枪'\n用消音手枪射击一个地方,你就会瞬移过去\n散弹枪打出的子弹会爆炸\n","Okay","");
               return 1;
	}
	if(GameMode[playerid]==11)//炮弹飞车
	{
               SetPlayerVirtualWorld(playerid,909);
               SetPlayerPos(playerid,367.5442,2499.9727,16.1472);
               SetPlayerInterior(playerid,0);
               DestroyVehicle(PV[playerid]);
               PV[playerid]=CreateVehicle(429,367.5442,2499.9727,82.1472,279.2771,0,0,120);
               LinkVehicleToInterior(PV[playerid],0);
               SetVehicleVirtualWorld(PV[playerid],909);
               SetVehiclePos(playerid,367.5442,2499.9727,82.1472);
               if(!IsVehicleHot(PV[playerid])){AddVehicleMissiles(PV[playerid],1.1,0.0);}
               SetPVarInt(playerid,"bseted",0);
               Dialog(playerid,999,DIALOG_STYLE_MSGBOX,"炮弹飞车","输入/rocket来装填炮弹!!!\n按2发射炮弹!!!\n注意,当你的车着火时会马上爆炸!!!","Okay","");
               return 1;
	}
	return 1;
	}
    
    	//---------------------------
	if(GodMode[playerid] == 1)
	{
        SetPlayerHealth(playerid, FLOAT_INFINITY);
	}
	if(PlayerInfo[playerid][pWeapon]==1)
	{
	GivePlayerWeapon(playerid, 9, 9999);
					GivePlayerWeapon(playerid, 23, 9999);
					GivePlayerWeapon(playerid, 27, 9999);
					GivePlayerWeapon(playerid, 32, 9999);
					GivePlayerWeapon(playerid, 31, 9999);
					GivePlayerWeapon(playerid, 34, 9999);
	}
	if(PlayerInfo[playerid][pWeapon]==2)
	{
	GivePlayerWeapon(playerid, 1, 9999);
					GivePlayerWeapon(playerid, 5, 9999);
					GivePlayerWeapon(playerid, 25, 9999);
					GivePlayerWeapon(playerid, 28, 9999);
					GivePlayerWeapon(playerid, 30, 9999);
					GivePlayerWeapon(playerid, 33, 9999);
					GivePlayerWeapon(playerid, 41, 9999);

	}
	if(PlayerInfo[playerid][pWeapon]==3)
	{
	GivePlayerWeapon(playerid, 4, 9999);
					GivePlayerWeapon(playerid, 24, 9999);
					GivePlayerWeapon(playerid, 26, 9999);
					GivePlayerWeapon(playerid, 32, 9999);
					GivePlayerWeapon(playerid, 31, 9999);

					GivePlayerWeapon(playerid, 42, 9999);
	}

	SetPlayerWeather(playerid,PlayerInfo[playerid][pW]);
    SetPlayerTime(playerid,PlayerInfo[playerid][pT],0);
	SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
	SetCameraBehindPlayer(playerid);
	SetPlayerInterior(playerid, 0);
	SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	SetPlayerVirtualWorld(playerid,0);
	Color(playerid);

    switch(PlayerInfo[playerid][pCustemSet])
    {
             case 0:
             {
             new Random = random(sizeof(RandomSpawns));
	         SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
             SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
             }
             case 1:
             {
             SetPlayerPos(playerid,PlayerInfo[playerid][pCustemX],PlayerInfo[playerid][pCustemY],PlayerInfo[playerid][pCustemZ]);
             SetPlayerFacingAngle(playerid,PlayerInfo[playerid][pCustemA]);
             SetPlayerInterior(playerid,PlayerInfo[playerid][pCustemI]);
             SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][pCustemV]);
             }
             case 2:
             {
             SetPlayerPos(playerid,PlayerInfo[playerid][pCustemX],PlayerInfo[playerid][pCustemY],PlayerInfo[playerid][pCustemZ]);
             SetPlayerFacingAngle(playerid,PlayerInfo[playerid][pCustemA]);
             SetPlayerInterior(playerid,PlayerInfo[playerid][pCustemI]);
             SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][pCustemV]);
			 Freeze(playerid);
             }
    }
	new file[256];
    new name[24];
    new f1[15],f2[15],f3[15],f4[15],f5[15],f6[15],f7[15],f8[15],f9[15],f10[15],f11[15];
    GetPlayerName(playerid,name,24);
    format(file,sizeof(file),"Player Objects/%s.ini",name);
    if(!dini_Exists(file)) return 1;
    for(new x;x<MAX_OSLOTS;x++)
	{
	    format(f1,15,"O_Model_%d",x);
		format(f2,15,"O_Bone_%d",x);
		format(f3,15,"O_OffX_%d",x);
  		format(f4,15,"O_OffY_%d",x);
		format(f5,15,"O_OffZ_%d",x);
		format(f6,15,"O_RotX_%d",x);
		format(f7,15,"O_RotY_%d",x);
		format(f8,15,"O_RotZ_%d",x);
		format(f9,15,"O_ScaleX_%d",x);
		format(f10,15,"O_ScaleY_%d",x);
		format(f11,15,"O_ScaleZ_%d",x);
	    if(dini_Int(file,f1)!=0)
	    {
	        SetPlayerAttachedObject(playerid,x,dini_Int(file,f1),dini_Int(file,f2),dini_Float(file,f3),dini_Float(file,f4),dini_Float(file,f5),dini_Float(file,f6),dini_Float(file,f7),dini_Float(file,f8),dini_Float(file,f9),dini_Float(file,f10),dini_Float(file,f11));
		}
	}


    
	//---------------------------
    return 1;
}



Re: public OnPlayerSpawn(playerid) dosen`t work - 3417512908 - 18.06.2018

anyone??


Re: public OnPlayerSpawn(playerid) dosen`t work - Alvitr - 18.06.2018

you should check is the function OnPlayerSpawn has been called or not,
if not,check all filterscripts
if called,you can using crashdetect to check where just stop working in this callback.
Quote:

如果是直接從別的版本升級上0.3.DL應該不會有任何問題,現在知道除了VirtualWorld同步有 問題外,還有0.3.DL新增的一些東西有問題




Re: public OnPlayerSpawn(playerid) dosen`t work - Sew_Sumi - 18.06.2018

24 hour bumps only.

If any of your filterscripts are using return 0 in the callback, that'll likely stop it. As Alvitr said, check it's being called by adding in print lines for each file, in that callback on all.

Код:
print("Car FS OnPlayerSpawn");
And do it for each FS with different tags, the last one to call it, will be the one returning 0.