SA-MP Forums Archive
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: Problem (/showthread.php?tid=578408)



Problem - Kruno88 - 19.06.2015

Код:
public OnPlayerSpawn(playerid)
{
	if (IsPlayerNPC(playerid)) {
		new slot = -1;
		for (new i = 0; i < MAX_RNPC_POLICE; i++) {
			if (ZNPC[i][ZNPC_NPCID] == playerid) {
				slot = i;
				break;
			}
		}

		if (slot > -1) {
			SetPlayerSkin(playerid, ZNPC[slot][ZNPC_SKIN]);
		}
	}
	CallLocalFunction("RNPC_OnPlayerSpawn", "i", playerid);
}//216
Код:
new ZNPC[MAX_RNPC_POLICE][ZNPC_enum] = {{-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1},
	{-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1},
	{-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1}, {-1, -1, 0.0, 0.0, 0.0, 0, 0, -1} };//19
Код:
C:\Users\Korisnik\Desktop\Kruno programi\Zombie RP\filterscripts\Zombienpcs.pwn(29) : error 052: multi-dimensional arrays must be fully initialized
C:\Users\Korisnik\Desktop\Kruno programi\Zombie RP\filterscripts\Zombienpcs.pwn(216) : warning 209: function "RNPC_OnPlayerSpawn" should return a value
Who ever solves this gets REP+.


Re: Problem - rappy93 - 19.06.2015

For the second error you have to add 'return 1;' at the end of the RNPC_OnPlayerSpawn or at OnPlayerSpawn.

Something like this :

PHP код:
public OnPlayerSpawn(playerid)
{
    if (
IsPlayerNPC(playerid)) {
        new 
slot = -1;
        for (new 
0MAX_RNPC_POLICEi++) {
            if (
ZNPC[i][ZNPC_NPCID] == playerid) {
                
slot i;
                break;
            }
        }

        if (
slot > -1) {
            
SetPlayerSkin(playeridZNPC[slot][ZNPC_SKIN]);
        }
    }
    
CallLocalFunction("RNPC_OnPlayerSpawn""i"playerid);
    return 
1;

The other one I'm not really sure.