Problem(error/warning): Izbacuje mi ovo u server.log, znam da je u pitanju nesto pod OnPlayerDeath, ali ne znam tacno sta, ako bi mogao neko da mi pomogne, bio bih mu veoma zahvalan. :D . PS: Pokusavao sam da optimizujem malo mod, jer me jebe i acks limit. Pre ovoga se ovo nije desavalo...
Deo skripte: [pawn]public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
if(InDM[playerid] != 0)
{
for(new i = 0; i <= GetPlayerPoolSize(); i++)
{
new string[85];
if(InDM == 1)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
else if(InDM == 2)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
else if(InDM == 3)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
}
}
SendDeathMessage( killerid, playerid, reason );
PlayerInfo[killerid][pUbistva]++;
PlayerInfo[killerid][pSkor]++;
SetPlayerScore(killerid, PlayerInfo[killerid][pSkor] );
PlayerInfo[killerid][pNovac] = PlayerInfo[killerid][pNovac] + 500;
ResetPlayerMoney(killerid); GivePlayerMoney(killerid, PlayerInfo[killerid][pNovac] );
PlayerInfo[playerid][pSmrti]++; SavePlayer( killerid ); SavePlayer( playerid );
SendDeathMessage( INVALID_PLAYER_ID, playerid, reason );
PlayerInfo[playerid][pSmrti]++; SavePlayer ( playerid );
}
Mrtva_Kamera[playerid] = 1;
if(Mrtva_Kamera[playerid] == 1)
{
Mrtva_Kamera[playerid] = 0;
if(Ubijen_Kamera[playerid] != INVALID_PLAYER_ID)
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, killerid);
GameTextForPlayer(playerid, "Spawn is in 3 seconds!", 3000, 4);
SetTimerEx("Specaj_Igraca", 5000, false, "i", playerid);
}
else
{
TogglePlayerSpectating(playerid, 0);
}
new string[128], Name[128];
GetPlayerName(killerid, Name, sizeof(Name));
PlayerTotalKills[killerid]++;
PlayerTotalKills[playerid] = 0;
if(PlayerTotalKills[killerid] == 3) {
format(string, sizeof(string), ""SVETLOPLAVA"(SPREE): "BELA"%s "SVETLOPLAVA"is on a "BELA"3 "SVETLOPLAVA"killing spree!", Name);
SCMTA(-1, string);
return 1;
}
if(PlayerTotalKills[killerid] == 5) {
format(string, sizeof(string), ""SVETLOPLAVA"(SPREE): "BELA"%s "SVETLOPLAVA"is on a "BELA"5 "SVETLOPLAVA"killing spree!", Name);
SCMTA(-1, string);
return 1;
}
if(PlayerTotalKills[killerid] == 8) {
format(string, sizeof(string), ""SVETLOPLAVA"(SPREE): "BELA"%s "SVETLOPLAVA"is on a "BELA"8 "SVETLOPLAVA"killing spree!", Name);
SCMTA(-1, string);
return 1;
}
if(PlayerTotalKills[killerid] == 10) {
format(string, sizeof(string), ""SVETLOPLAVA"(SPREE): "BELA"%s "SVETLOPLAVA"is on a "BELA"10 "SVETLOPLAVA"killing spree!", Name);
SCMTA(-1, string);
return 1;
}
if(PlayerTotalKills[killerid] == 15) {
format(string, sizeof(string), ""SVETLOPLAVA"(SPREE): "BELA"%s "SVETLOPLAVA"is on a "BELA"15 "SVETLOPLAVA"killing spree!", Name);
SCMTA(-1, string);
return 1;
}
return 1;
}[/pawn]
Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): [20:16:20] [debug] Run time error 4: "Array index out of bounds"
[20:16:20] [debug] AMX backtrace:
[20:16:20] [debug] #0 0005fa10 in public WC_OnPlayerDeath (3, 65535, 55) from rdm.amx
[20:16:20] [debug] #1 0004defc in ?? (3, 0, 65535, 55, 0, 0) from rdm.amx
[20:16:20] [debug] #2 000398b0 in ?? (3, 0, -1082130432) from rdm.amx
[20:16:20] [debug] #3 00063b24 in public cmd_kill (3, 22860028) from rdm.amx
[20:16:20] [debug] #4 native CallLocalFunction () from samp03svr
[20:16:20] [debug] #5 00038778 in public OnPlayerCommandText (3, 22859996) from rdm.amx
Slika/video ingame problema(obavezno ako je ingame problem): //
ne mozes ovo [pawn]GetPlayerName(killerid, Name, sizeof(Name));[/pawn] bez invalid playerid
Citat: Terza Lazarevic poslato Jul 25, 2019, 13:33:24 POSLE PODNE
ne mozes ovo [pawn]GetPlayerName(killerid, Name, sizeof(Name));[/pawn] bez invalid playerid
Ima vec [pawn]if(killerid != INVALID_PLAYER_ID)[/pawn]
Citat: Ñ,ιмιc poslato Jul 25, 2019, 13:40:56 POSLE PODNE
Ima vec [pawn]if(killerid != INVALID_PLAYER_ID)[/pawn]
ne, nema
Ako koristis u OnPlayerDeath "killerid" i pritom želiÅ¡ da igraÄu uvećaÅ¡ ubistva moraÅ¡ koristiti
[pawn]if(killerid != INVALID_PLAYER_ID)[/pawn]
U tvom sluÄaju ti mu uzimaÅ¡ ime a da pritom nisi ni proverio da li je to igraÄ uopste koji ga je ubio
[pawn]GetPlayerName(killerid, Name, sizeof(Name));[/pawn]
.. koliko vidim ispod toga još koristiš killerid bez ove provere
Citat: Terza Lazarevic poslato Jul 25, 2019, 14:04:31 POSLE PODNE
Ako koristis u OnPlayerDeath "killerid" i pritom želiÅ¡ da igraÄu uvećaÅ¡ ubistva moraÅ¡ koristiti
[pawn]if(killerid != INVALID_PLAYER_ID)[/pawn]
U tvom sluÄaju ti mu uzimaÅ¡ ime a da pritom nisi ni proverio da li je to igraÄ uopste koji ga je ubio
[pawn]GetPlayerName(killerid, Name, sizeof(Name));[/pawn]
.. koliko vidim ispod toga još koristiš killerid bez ove provere
Meni sve lepo radi, neki put se desi da se pomesa skor igracima, to je do cuvanja, jel bi mogao da mi sredis to?
Citat: Ñ,ιмιc poslato Jul 25, 2019, 14:13:28 POSLE PODNE
Meni sve lepo radi, neki put se desi da se pomesa skor igracima, to je do cuvanja, jel bi mogao da mi sredis to?
Ti mene oÄigledno ne sluÅ¡aÅ¡ :D
Citat: Terza Lazarevic poslato Jul 25, 2019, 14:14:51 POSLE PODNE
Ti mene oÄigledno ne sluÅ¡aÅ¡ :D
Ne brt, sve lepo procitam kako mi napises, ali ne mogu da skontam
[pawn]
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(killerid != INVALID_PLAYER_ID)
{
if(InDM[playerid] != 0)
{
for(new i = 0; i <= GetPlayerPoolSize(); i++)
{
new string[85];
if(InDM == 1)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
else if(InDM == 2)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
else if(InDM == 3)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
}
}
Mrtva_Kamera[playerid] = 1;
if(Mrtva_Kamera[playerid] == 1)
{
Mrtva_Kamera[playerid] = 0;
if(Ubijen_Kamera[playerid] != INVALID_PLAYER_ID)
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, killerid);
GameTextForPlayer(playerid, "Spawn is in 3 seconds!", 3000, 4);
SetTimerEx("Specaj_Igraca", 5000, false, "i", playerid);
}
}
else
{
TogglePlayerSpectating(playerid, 0);
}
new string[110], Name[MAX_PLAYER_NAME];
GetPlayerName(killerid, Name, sizeof(Name));
PlayerTotalKills[killerid]++;
PlayerTotalKills[playerid] = 0;
switch(PlayerTotalKills[killerid])
{
case 3,5,8,10,15:
{
format(string, sizeof(string), ""SVETLOPLAVA"(SPREE): "BELA"%s "SVETLOPLAVA"is on a "BELA"%d "SVETLOPLAVA"killing spree!", Name, PlayerTotalKills[killerid]);
SCMTA(-1, string);
}
}
PlayerInfo[killerid][pUbistva]++;
PlayerInfo[killerid][pSkor]++;
SavePlayer(killerid);
SetPlayerScore(killerid, PlayerInfo[killerid][pSkor]);
PlayerInfo[killerid][pNovac] += 500;
ResetPlayerMoney(killerid);
GivePlayerMoney(killerid, PlayerInfo[killerid][pNovac]);
PlayerInfo[playerid][pSmrti]++;
SavePlayer(playerid);
}
return 1;
}
[/pawn]
Evo ti onda ovako, vidi da li radi ..
Citat: Terza Lazarevic poslato Jul 25, 2019, 15:20:46 POSLE PODNE
[pawn]
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(killerid != INVALID_PLAYER_ID)
{
if(InDM[playerid] != 0)
{
for(new i = 0; i <= GetPlayerPoolSize(); i++)
{
new string[85];
if(InDM == 1)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
else if(InDM == 2)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
else if(InDM == 3)
{
format(string, sizeof(string), ""ROZA"(death)"BELA" %s "ROZA"was slain "BELA"%s.", GetName(killerid), GetName(playerid));
SCM(i, -1, string);
}
}
}
Mrtva_Kamera[playerid] = 1;
if(Mrtva_Kamera[playerid] == 1)
{
Mrtva_Kamera[playerid] = 0;
if(Ubijen_Kamera[playerid] != INVALID_PLAYER_ID)
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, killerid);
GameTextForPlayer(playerid, "Spawn is in 3 seconds!", 3000, 4);
SetTimerEx("Specaj_Igraca", 5000, false, "i", playerid);
}
}
else
{
TogglePlayerSpectating(playerid, 0);
}
new string[110], Name[MAX_PLAYER_NAME];
GetPlayerName(killerid, Name, sizeof(Name));
PlayerTotalKills[killerid]++;
PlayerTotalKills[playerid] = 0;
switch(PlayerTotalKills[killerid])
{
case 3,5,8,10,15:
{
format(string, sizeof(string), ""SVETLOPLAVA"(SPREE): "BELA"%s "SVETLOPLAVA"is on a "BELA"%d "SVETLOPLAVA"killing spree!", Name, PlayerTotalKills[killerid]);
SCMTA(-1, string);
}
}
PlayerInfo[killerid][pUbistva]++;
PlayerInfo[killerid][pSkor]++;
SavePlayer(killerid);
SetPlayerScore(killerid, PlayerInfo[killerid][pSkor]);
PlayerInfo[killerid][pNovac] += 500;
ResetPlayerMoney(killerid);
GivePlayerMoney(killerid, PlayerInfo[killerid][pNovac]);
PlayerInfo[playerid][pSmrti]++;
SavePlayer(playerid);
}
return 1;
}
[/pawn]
Evo ti onda ovako, vidi da li radi ..
Radi sve, ali jebe me i ackslimit, jel mi mozes pomoci kako da ga resim? Znam da je u pitanju optimizacija ali ne znam do cega je konkretno, kako da saznam?