NPC Skin - Problem - 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: NPC Skin - Problem (
/showthread.php?tid=492567)
NPC Skin - Problem -
LuisR - 04.02.2014
Ive search alot topics about this problem, but nothing help me.
I try change the skin to my npc but it dont change, including i put spawnInfo and nothing happen, check it. this is the OnPlayerSpawn of my filtescript.
PHP код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid))
{
new npcname[24];
GetPlayerName(playerid, npcname, 24);
if(!strcmp(npcname, "Unity_Driver", true))
{
SetPlayerSkin(playerid, 150);
PutPlayerInVehicle(playerid, Autobus_BusUnitySf, 0);
Attach3DTextLabelToPlayer(Text3d_BusUnitySf, playerid, 0.0, 0.0, 0.0);
}
}
return 1;
}
All work fine, the npc is put in the vehicle, but he dont wanna change the skin, someone can help me with this >.< this make me crazy.
Respuesta: NPC Skin - Problem -
LuisR - 06.02.2014
Bump
Re: NPC Skin - Problem -
BullseyeHawk - 06.02.2014
As I might suspect, you might be calling three functions too fast. I had this problem too.
Attempt to create a timer to re-skin the NPC. (Don't forget to reset player into the vehicle, unless you want the gameserver to crash.. Or, the players just..)
pawn Код:
forward NPC_ResetSkin(npcid);
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid))
{
new npcname[24];
GetPlayerName(playerid, npcname, 24);
if(!strcmp(npcname, "Unity_Driver", true))
{
SetPlayerSkin(playerid, 150); // I'd suggest to move this code to the new function
PutPlayerInVehicle(playerid, Autobus_BusUnitySf, 0); // I'd suggest to move this code to the new function
Attach3DTextLabelToPlayer(Text3d_BusUnitySf, playerid, 0.0, 0.0, 0.0); // I'd suggest to move this code to the new function
SetTimerEx("NPC_ResetSkin", 1000, false, "d", playerid);
}
}
return 1;
}
public NPC_ResetSkin(npcid)
{
// your code here.
}