Quote:
Originally Posted by Konstantinos
It shouldn't have crashed the server because sizeof returns 1 (it's correct) and it should be called only once with i equal to 0.
You can normally debug it:
pawn Код:
public OnPlayerSpawn(playerid) { if(IsPlayerNPC(playerid)) { printf("DEBUG: sizeof(bus) -> %i", sizeof(bus)); new npcname[MAX_PLAYER_NAME]; GetPlayerName(playerid, npcname, sizeof(npcname)); for(new i = 0; i < sizeof(bus); i++) { printf("DEBUG: OnPlayerSpawn -> i: %i", i); if(!strcmp(npcname, bus[i][0][0], true)) { SetPlayerSkin(playerid, 253); PutPlayerInVehicle(playerid, bus[i][3][0], 0); } } return 1; } return 1; }
and let's see what size is going to return and how many times the loop is called.
Crashdetect can also help on the debugging by compiling your scripts with debug info (-d3): https://github.com/Zeex/samp-plugin-...ith-debug-info
Do both and start the server, let the NPC connect to the server and post again what it printed.
|
WTF, your code didn't crash the server (neither did mine, but crashdetect showed stuff).
Код:
[20:11:30] [npc:join] Fred has joined the server (0:127.0.0.1)
[20:11:30] DEBUG: sizeof(bus) -> 1
[20:11:30] DEBUG: OnPlayerSpawn -> i: 0
[20:11:45] [npc:part] Fred has left the server (0:0)
That is correct, I think, as Fred is the first player to join and there is one bus (Fred). He immediately disconnects, tho. I have no anticheat/register (I use the pawno>new gamemode)
P.S. Big clucker