Heyho, mein Server crasht nach 1-2 Min wenn ich /swatduty gehe.
Hier der Code:
Oben:
new PlayerTrueName[MAX_PLAYERS][MAX_PLAYER_NAME];
-----------------------------------------------------------------------------
Dann halt der Command:
if(strcmp(cmd, "/swatduty", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
if (PlayerInfo[playerid][pMember] == 22 || PlayerInfo[playerid][pLeader] == 22)
{
if (IsPlayerInRangeOfPoint(playerid,3.0,254.2361,76.9261,1003.6406) ||IsPlayerInRangeOfPoint(playerid,3.0, 217.5230,184.4352,1003.0313)
|| PlayerInfo[playerid][pLocal] != 255)
{
if(OnDuty[playerid]==0)
{
SetPlayerSkin(playerid,285);
OnDuty[playerid] = 1;
new DerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,DerName,sizeof(DerName));
PlayerTrueName[playerid] = DerName;
new rand = random(19);
if(rand == 0)return SetPlayerName(playerid,"Alpha");
if(rand == 1)return SetPlayerName(playerid,"Beta");
if(rand == 2)return SetPlayerName(playerid,"Gamma");
if(rand == 3)return SetPlayerName(playerid,"Omega");
if(rand == 4)return SetPlayerName(playerid,"Delta");
if(rand == 5)return SetPlayerName(playerid,"Epsilon");
if(rand == 6)return SetPlayerName(playerid,"Zeta");
if(rand == 7)return SetPlayerName(playerid,"Eta");
if(rand == 8)return SetPlayerName(playerid,"Theta");
if(rand == 9)return SetPlayerName(playerid,"Iota");
if(rand == 10)return SetPlayerName(playerid,"Kappa");
if(rand == 11)return SetPlayerName(playerid,"Lambda");
if(rand == 12)return SetPlayerName(playerid,"Omikron");
if(rand == 13)return SetPlayerName(playerid,"Rho");
if(rand == 14)return SetPlayerName(playerid,"Sigma");
if(rand == 15)return SetPlayerName(playerid,"Tau");
if(rand == 16)return SetPlayerName(playerid,"Ypsilon");
if(rand == 17)return SetPlayerName(playerid,"Psi");
if(rand == 18)return SetPlayerName(playerid,"Omega");
}
else if(OnDuty[playerid]==1)
{
SetPlayerName(playerid,PlayerTrueName[playerid]);
SetPlayerSkin(playerid,280);
ResetPlayerWeapons(giveplayerid);
PlayerInfo[giveplayerid][pGun1] = 0; PlayerInfo[giveplayerid][pAmmo1] = 0;
PlayerInfo[giveplayerid][pGun2] = 0; PlayerInfo[giveplayerid][pAmmo2] = 0;
PlayerInfo[giveplayerid][pGun3] = 0; PlayerInfo[giveplayerid][pAmmo3] = 0;
PlayerInfo[giveplayerid][pGun4] = 0; PlayerInfo[giveplayerid][pAmmo4] = 0;
SetPlayerColor(playerid,COLOR_WHITE); // white
OnDuty[playerid] = 0;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " Du bist in keiner Umkleide !");
return 1;
}
}
}
return 1;
}
SWAT Duty bringt Server zum absturz!
- keeev.
- Geschlossen
- Erledigt
-
-
Ich weiss nicht, ob es die Ursache ist, aber warum benutzt du für die rand Variable immer und immer wieder "if" ?
Benutzt lieber switch und case, es ist schneller als if..switch(rand) {
case 0: { SetPlayerName(playerid, "Alpha"); }
case 1: { SetPlayerName(playerid, "Beta"); }
}Edit: Weiss nicht ob ich switch und case so richtig benutzt habe, aber ich glaube. Falls nicht korrigiert mich bitte und verzeiht mir.
-
Der Server stürzt immernoch ab!
Immer wenn ich SWAT Duty bin, und ein anderer den Server betritt geht der Server Offline?
-
Liegt wahrscheinlich am Random, woran genau...
Villt. bei den if außer beim ersten ein Else davor?
Obwohl ich mir das nicht vorstellen kann. Aber gab schon so manche Verwunderung.
- Tomsen
-
Bei dem Case, ändert sich der Name NICHT.
-
breadfish.de
Hat das Thema geschlossen.