Guten Morgen,
ich wollte ein Gangfight System (nicht von mir geschrieben) von file auf MySQL R5 umschreiben. Aber mir fällt es ziemlich schwer und deshalb wollte ich euch mal Fragen, ob ihr mir auf die Sprünge helfen könnt. Die Verbindung zu MySQL Datenbank existiert bereits schon.
public Fight_Init()
{
Fight = TextDrawCreate(241.000000,351.000000,"Gangfight:");
TextDrawAlignment(Fight,0);
TextDrawBackgroundColor(Fight,0x000000ff);
TextDrawFont(Fight,0);
TextDrawLetterSize(Fight,1.200000,1.500000);
TextDrawColor(Fight,0xffffffff);
TextDrawSetOutline(Fight,1);
TextDrawSetProportional(Fight,1);
TextDrawSetShadow(Fight,1);
if(!fexist(FIGHT_FILE))
{
new File:fFile=fopen(FIGHT_FILE,io_write);
for(new fs;fs<sizeof(FightSystem);fs++)
fwrite(fFile,"15 -255 0 0 0\r\n");
fclose(fFile);
}
new File:fFile=fopen(FIGHT_FILE,io_read),Content[64],fs;
while(fread(fFile,Content) && fs < sizeof(FightSystem))
{
FightSystem[fs][fsWinFaction] = TextDrawCreate(206.000000,379.000000," ");
TextDrawAlignment(FightSystem[fs][fsWinFaction],0);
TextDrawBackgroundColor(FightSystem[fs][fsWinFaction],0x000000ff);
TextDrawFont(FightSystem[fs][fsWinFaction],0);
TextDrawLetterSize(FightSystem[fs][fsWinFaction],0.899999,1.300000);
TextDrawColor(FightSystem[fs][fsWinFaction],0xffffffff);
TextDrawSetShadow(FightSystem[fs][fsWinFaction],1);
TextDrawSetOutline(FightSystem[fs][fsWinFaction],1);
TextDrawSetProportional(FightSystem[fs][fsWinFaction],1);
FightSystem[fs][fsLoseFaction] = TextDrawCreate(206.000000,400.000000," ");
TextDrawAlignment(FightSystem[fs][fsLoseFaction],0);
TextDrawBackgroundColor(FightSystem[fs][fsLoseFaction],0x000000ff);
TextDrawFont(FightSystem[fs][fsLoseFaction],0);
TextDrawLetterSize(FightSystem[fs][fsLoseFaction],0.799999,1.300000);
TextDrawColor(FightSystem[fs][fsLoseFaction],0xffffffff);
TextDrawSetShadow(FightSystem[fs][fsLoseFaction],1);
TextDrawSetOutline(FightSystem[fs][fsLoseFaction],1);
TextDrawSetProportional(FightSystem[fs][fsLoseFaction],1);
FightSystem[fs][fsWinKills] = TextDrawCreate(328.000000,379.000000," ");
TextDrawAlignment(FightSystem[fs][fsWinKills],0);
TextDrawBackgroundColor(FightSystem[fs][fsWinKills],0x000000ff);
TextDrawFont(FightSystem[fs][fsWinKills],0);
TextDrawLetterSize(FightSystem[fs][fsWinKills],0.599999,1.200000);
TextDrawColor(FightSystem[fs][fsWinKills],0xffffffff);
TextDrawSetShadow(FightSystem[fs][fsWinKills],1);
TextDrawSetOutline(FightSystem[fs][fsWinKills],1);
TextDrawSetProportional(FightSystem[fs][fsWinKills],1);
FightSystem[fs][fsLoseKills] = TextDrawCreate(328.000000,400.000000," ");
TextDrawAlignment(FightSystem[fs][fsLoseKills],0);
TextDrawBackgroundColor(FightSystem[fs][fsLoseKills],0x000000ff);
TextDrawFont(FightSystem[fs][fsLoseKills],0);
TextDrawLetterSize(FightSystem[fs][fsLoseKills],0.599999,1.300000);
TextDrawColor(FightSystem[fs][fsLoseKills],0xffffffff);
TextDrawSetShadow(FightSystem[fs][fsLoseKills],1);
TextDrawSetOutline(FightSystem[fs][fsLoseKills],1);
TextDrawSetProportional(FightSystem[fs][fsLoseKills],1);
StripNewLine(Content);
sscanf(Content,"dddddd",FightSystem[fs][fsOwnerFaction],FightSystem[fs][fsAttackFaction],FightSystem[fs][fsKillsOfOwner],FightSystem[fs][fsKillsOfAttack],FightSystem[fs][fsFightTime],FightSystem[fs][fsLastFight]);
FightSystem[fs][fsCtfOfOwner][0] = -255;
FightSystem[fs][fsCtfOfOwner][1] = 0;
FightSystem[fs][fsCtfOfAttack][0] = -255;
FightSystem[fs][fsCtfOfAttack][1] = 0;
FightSystem[fs][fsZoneID] = GangZoneCreate(FightSystem[fs][fsMinX],FightSystem[fs][fsMinY],FightSystem[fs][fsMaxX],FightSystem[fs][fsMaxY]);
FightSystem[fs][fsFlagOfOwner] = CreateObject(2993,FightSystem[fs][fsCtfOfOwnerx],FightSystem[fs][fsCtfOfOwnery],(FightSystem[fs][fsCtfOfOwnerz]-1.0),0.0,0.0,0.0,150.0);
FightSystem[fs][fsFlagOfAttack] = CreateObject(2993,FightSystem[fs][fsCtfOfAttackx],FightSystem[fs][fsCtfOfAttacky],(FightSystem[fs][fsCtfOfAttackz]-1.0),0.0,0.0,0.0,150.0);
if(FightSystem[fs][fsFightTime] && FightSystem[fs][fsAttackFaction] != -255)
{
new fsText[64];
if(FightSystem[fs][fsKillsOfOwner] > FightSystem[fs][fsKillsOfAttack])
{
format(fsText,sizeof(fsText),"%s",GetFactionNameOfFaction(FightSystem[fs][fsOwnerFaction]));
TextDrawSetString(FightSystem[fs][fsWinFaction],fsText);
format(fsText,sizeof(fsText),"%02d Punkte",FightSystem[fs][fsKillsOfOwner]);
TextDrawSetString(FightSystem[fs][fsWinKills],fsText);
format(fsText,sizeof(fsText),"%s",GetFactionNameOfFaction(FightSystem[fs][fsAttackFaction]));
TextDrawSetString(FightSystem[fs][fsLoseFaction],fsText);
format(fsText,sizeof(fsText),"%02d Punkte",FightSystem[fs][fsKillsOfAttack]);
TextDrawSetString(FightSystem[fs][fsLoseKills],fsText);
}
else if(FightSystem[fs][fsKillsOfAttack] > FightSystem[fs][fsKillsOfOwner])
{
format(fsText,sizeof(fsText),"%s",GetFactionNameOfFaction(FightSystem[fs][fsAttackFaction]));
TextDrawSetString(FightSystem[fs][fsWinFaction],fsText);
format(fsText,sizeof(fsText),"%02d Punkte",FightSystem[fs][fsKillsOfAttack]);
TextDrawSetString(FightSystem[fs][fsWinKills],fsText);
format(fsText,sizeof(fsText),"%s",GetFactionNameOfFaction(FightSystem[fs][fsOwnerFaction]));
TextDrawSetString(FightSystem[fs][fsLoseFaction],fsText);
format(fsText,sizeof(fsText),"%02d Punkte",FightSystem[fs][fsKillsOfOwner]);
TextDrawSetString(FightSystem[fs][fsLoseKills],fsText);
}
else
{
format(fsText,sizeof(fsText),"%s",GetFactionNameOfFaction(FightSystem[fs][fsOwnerFaction]));
TextDrawSetString(FightSystem[fs][fsWinFaction],fsText);
format(fsText,sizeof(fsText),"%02d Punkte",FightSystem[fs][fsKillsOfOwner]);
TextDrawSetString(FightSystem[fs][fsWinKills],fsText);
format(fsText,sizeof(fsText),"%s",GetFactionNameOfFaction(FightSystem[fs][fsAttackFaction]));
TextDrawSetString(FightSystem[fs][fsLoseFaction],fsText);
format(fsText,sizeof(fsText),"%02d Punkte",FightSystem[fs][fsKillsOfAttack]);
TextDrawSetString(FightSystem[fs][fsLoseKills],fsText);
}
}
for(new i;i<GetMaxPlayers();i++)
{
if(IsPlayerConnected(i))
{
SetPVarInt(i,"Spawned",1);
GangZoneShowForPlayer(i,FightSystem[fs][fsZoneID],GetZoneColorOfFaction(FightSystem[fs][fsOwnerFaction]));
if(FightSystem[fs][fsAttackFaction] != -255 && FightSystem[fs][fsFightTime])
{
GangZoneFlashForPlayer(i,FightSystem[fs][fsZoneID],GetZoneColorOfFaction(FightSystem[fs][fsAttackFaction]));
if(GetPlayerFaction(i) == FightSystem[fs][fsAttackFaction] || GetPlayerFaction(i) == FightSystem[fs][fsOwnerFaction])
{
TextDrawShowForPlayer(i,Fight);
TextDrawShowForPlayer(i,FightSystem[fs][fsWinFaction]);
TextDrawShowForPlayer(i,FightSystem[fs][fsLoseFaction]);
TextDrawShowForPlayer(i,FightSystem[fs][fsWinKills]);
TextDrawShowForPlayer(i,FightSystem[fs][fsLoseKills]);
}
}
}
}
fs++;
}
fclose(fFile);
FightTimer[0] = SetTimer("FightUpdate_1",1003,true);
FightTimer[1] = SetTimer("FightUpdate_2",60017,true);
}
Mit freundlichen Grüßen
Grapefruit