SA-MP Forums Archive
Help Me Please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help Me Please (/showthread.php?tid=268058)



Help Me Please - HayZatic - 11.07.2011

My TeamScore is screwed up. the plan is , a person one Team 1 gets a kill The textdraw updates. BUT it waits for a enemy to kill the Player for the score to update.

Heres the Textdraw Place where its taking place.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendDeathMessage(killerid,reason,playerid);
	SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
    if(GetPlayerTeam(killerid) == 1)
    {
        RussiaScore++; //Sets team1score
        new newtext[41];
        RussiaScore = GetPlayerScore(playerid);
        USAScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "USA's Score: %d", RussiaScore);
        TextDrawSetString(Text:Textdraw0, newtext);
    }
    if(GetPlayerTeam(killerid) == 2)
    {
        USAScore++; //Sets team2score
        new newtext[41];
        USAScore = GetPlayerScore(playerid);
        RussiaScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "Russia's Score: %d", USAScore);
        TextDrawSetString(Text:Textdraw1, newtext);
    }
    if(RussiaScore == 5 || USAScore == 5)
    {
        SendRconCommand("gmx"); //Restarts Server
    }
    return 1;
}



Re: Help Me Please - PrawkC - 11.07.2011

make a function that refreshes everyone textdraws, because you need to show/hide textdraws for them to update, so just make like a ShowHideTD or something, then call it at the end of OnPlayerDeath


Re: Help Me Please - HayZatic - 11.07.2011

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
make a function that refreshes everyone textdraws, because you need to show/hide textdraws for them to update, so just make like a ShowHideTD or something, then call it at the end of OnPlayerDeath
Can you help set me on the right path?


Re: Help Me Please - Scenario - 11.07.2011

Create a stock function, make it hide a players TD's, then show them again. Call this whenever you need a TD to update.


Re: Help Me Please - PrawkC - 11.07.2011

pawn Код:
stock ShowHideTD(Text:td)
{
 TextDrawHideForAll(td);
 TextDrawShowForAll(td);
}



Re: Help Me Please - HayZatic - 11.07.2011

Hmm, Still Quite Confused. Where would the stock go and how would i bring it up for on player death


Re: Help Me Please - PrawkC - 11.07.2011

the stock would go anywhere in the script, its just like a function.. and add in ShowHideTD(YourTDName); before the return 1; on player death, and YourTdName would be the TD name you want to "update", so if you have more than one, do like ShowHideTD(td1);, ShowHideTD(td2); etc ..


Re: Help Me Please - HayZatic - 11.07.2011

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendDeathMessage(killerid,reason,playerid);
	SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
	ShowHideTD(Textdraw0);
	ShowHideTD(Textdraw1);
    if(GetPlayerTeam(killerid) == 1)
    {
        RussiaScore++; //Sets team1score
        new newtext[41];
        RussiaScore = GetPlayerScore(playerid);
        USAScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "USA's Score: %d", RussiaScore);
        TextDrawSetString(Text:Textdraw0, newtext);
    }
    if(GetPlayerTeam(killerid) == 2)
    {
        USAScore++; //Sets team2score
        new newtext[41];
        USAScore = GetPlayerScore(playerid);
        RussiaScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "Russia's Score: %d", USAScore);
        TextDrawSetString(Text:Textdraw1, newtext);
    }
    if(RussiaScore == 50 || USAScore == 50)
    {
        SendRconCommand("gmx"); //Restarts Server
    }
    return 1;
}
stock ShowHideTD(Text:td)
{
 TextDrawHideForAll(Textdraw0);
 TextDrawHideForAll(Textdraw1);
 TextDrawShowForAll(Textdraw0);
 TextDrawShowForAll(Textdraw1);
}
Thats how i have it and i get his

Код:
C:\Documents and Settings\Chris\Desktop\SAMP Server\gamemodes\WorldWar.pwn(339) : warning 203: symbol is never used: "td"
C:\Documents and Settings\Chris\Desktop\SAMP Server\gamemodes\WorldWar.pwn(417) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.



Re: Help Me Please - PrawkC - 11.07.2011

sigh

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid,reason,playerid);
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
    if(GetPlayerTeam(killerid) == 1)
    {
        RussiaScore++; //Sets team1score
        new newtext[41];
        RussiaScore = GetPlayerScore(playerid);
        USAScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "USA's Score: %d", RussiaScore);
        TextDrawSetString(Text:Textdraw0, newtext);
    }
    if(GetPlayerTeam(killerid) == 2)
    {
        USAScore++; //Sets team2score
        new newtext[41];
        USAScore = GetPlayerScore(playerid);
        RussiaScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "Russia's Score: %d", USAScore);
        TextDrawSetString(Text:Textdraw1, newtext);
    }
    if(RussiaScore == 5 || USAScore == 5)
    {
        SendRconCommand("gmx"); //Restarts Server
    }
    ShowHideTD(Textdraw0);
    ShowHideTD(Textdraw1);
    return 1;
}

stock ShowHideTD(Text:td)
{
    TextDrawHideForAll(td);
    TextDrawShowForAll(td);
}



Re: Help Me Please - HayZatic - 11.07.2011

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
sigh

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid,reason,playerid);
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
    if(GetPlayerTeam(killerid) == 1)
    {
        RussiaScore++; //Sets team1score
        new newtext[41];
        RussiaScore = GetPlayerScore(playerid);
        USAScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "USA's Score: %d", RussiaScore);
        TextDrawSetString(Text:Textdraw0, newtext);
    }
    if(GetPlayerTeam(killerid) == 2)
    {
        USAScore++; //Sets team2score
        new newtext[41];
        USAScore = GetPlayerScore(playerid);
        RussiaScore = GetPlayerScore(playerid);
        format(newtext, sizeof(newtext), "Russia's Score: %d", USAScore);
        TextDrawSetString(Text:Textdraw1, newtext);
    }
    if(RussiaScore == 5 || USAScore == 5)
    {
        SendRconCommand("gmx"); //Restarts Server
    }
    ShowHideTD(Textdraw0);
    ShowHideTD(Textdraw1);
    return 1;
}

stock ShowHideTD(Text:td)
{
    TextDrawHideForAll(td);
    TextDrawShowForAll(td);
}
Thanks :P