13.05.2012, 04:27
Hello,
This code is compiling usually more finally in turn, is not creating a TextDraw for each player, the first player enters and the other in, it updates the score with an ID, and so on.
If anyone could help me with this, and also give a code reviewed to see if it's alright, please.
Thank you.
This code is compiling usually more finally in turn, is not creating a TextDraw for each player, the first player enters and the other in, it updates the score with an ID, and so on.
If anyone could help me with this, and also give a code reviewed to see if it's alright, please.
Код:
#include <a_samp> #include <Dini> #include <ZCMD> #include <sscanf2> new KillsSpree[MAX_PLAYERS], Text:InfoSpree[MAX_PLAYERS], Text:BoxSpree; /*--------------------------------*-------------------------------------------*/ public OnPlayerConnect(playerid) { OnUpdateScore(playerid); LoginSpree(playerid); return 1; } /*--------------------------------*-------------------------------------------*/ public OnPlayerDisconnect(playerid) { SaveSpree(playerid); return 1; } /*--------------------------------*-------------------------------------------*/ public OnPlayerDeath(playerid, killerid, reason) { KillsSpree[killerid] ++; KillsSpree[playerid] = 0; OnUpdateScore(killerid); return 1; } /*--------------------------------*-------------------------------------------*/ public OnPlayerSpawn(playerid) { for(new x = 0; x < MAX_PLAYERS; x++) { if(!IsPlayerConnected(x)) continue; TextDrawShowForPlayer(playerid,BoxSpree); TextDrawShowForPlayer(playerid,InfoSpree[x]); } return 1; } /*--------------------------------*-------------------------------------------*/ public OnFilterScriptInit() { for(new x = 0; x < MAX_PLAYERS; x++) { InfoSpree[x](playerid) = TextDrawCreate(537.000000, 341.000000," "); TextDrawFont(InfoSpree[x], 2); TextDrawLetterSize(InfoSpree[x], 0.290000, 1.300000); TextDrawColor(InfoSpree[x], 0x0DB0DDFF); TextDrawSetOutline(InfoSpree[x], 1); TextDrawSetProportional(InfoSpree[x], 1); return 1; } BoxSpree = TextDrawCreate(634.000000, 340.000000, "-"); TextDrawBackgroundColor(BoxSpree, 255); TextDrawFont(BoxSpree, 1); TextDrawLetterSize(BoxSpree, 0.370000, 3.399998); TextDrawColor(BoxSpree, 0); TextDrawSetOutline(BoxSpree, 0); TextDrawSetProportional(BoxSpree, 1); TextDrawSetShadow(BoxSpree, 0); TextDrawUseBox(BoxSpree, 1); TextDrawBoxColor(BoxSpree, 80); TextDrawTextSize(BoxSpree, 529.000000, 21.000000); if(!fexist("sprees.ini")) dini_Create("sprees.ini"); return 1; } /*============================================================================================================*/ public OnPlayerUpdate(playerid) { OnUpdateScore(playerid); return 1; } /*============================================================================================================*/ stock OnUpdateScore(playerid) { for(new x = 0, y = GetMaxPlayers(); x != y; x++) { if(!IsPlayerConnected(x)) continue; new strings[100]; format(strings, sizeof(strings),"~w~Score: %d ~n~Spree: %d", GetPlayerScore(x), KillsSpree[x]); TextDrawSetString(InfoSpree[x], strings); } return true; } /*============================================================================================================*/ stock SaveSpree(playerid) { dini_IntSet("sprees.ini",PlayerName(playerid),KillsSpree[playerid]); return 1; } /*============================================================================================================*/ stock LoginSpree(playerid) { if(dini_Isset("sprees.ini",PlayerName(playerid))) KillsSpree[playerid] = (playerid,dini_Int("sprees.ini",PlayerName(playerid))); return 1; } /*============================================================================================================*/ stock PlayerName(playerid) { new Namei[MAX_PLAYERS]; GetPlayerName(playerid, Namei, sizeof(Namei)); return Namei; } /*================================================================================================*/