help with vote to give all health !!!
#1

Hi.

i have counter strike server and i want vote to give all health !!! for players

and if the vote = 7 give all players health...

example :

players dont have health.. they type /hl
and then send messege to all players, Str|ke vote to heal all (1/7)

like that... and when 7 player vote (/hl) and max votes (7/7) then automatically the server give all players health


plz help !!!
Reply
#2

Well I didn't get enough information about what you want. But, here's one similar, you might like it* . Compile & use it as a filterscript. If there is any problem I'm here!

* Find it in my post below.
Reply
#3

HellSphinX you forgot something in your script, players can vote multiple times, use the variable PlayerHasVoted to fix that.
Reply
#4

Just create 2 variables on top of your script:

pawn Код:
new HealVote = 0;
new PlayerVoted[MAX_PLAYERS];
Reset the Player Variable at OnPlayerConnect:
pawn Код:
PlayerVoted[playerid] = 0;
And here the command:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/hl", true) == 0)
    {
        if(PlayerVoted[playerid] == 0)
        {
            HealVote += 1;
            new string[64], name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string),"%s voted to heal everyone. (%d/7)", name, HealVote);
            SendClientMessageToAll(0xEB0000FF, string);
            PlayerVoted[playerid] = 1;
            if(HealVote >= 7)
            {
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    SetPlayerHealth(i, 100);
                    PlayerVoted[i] = 0;
                }
                SendClientMessageToAll(0xEB0000FF, "Everyone has been healed.");
                HealVote = 0;
            }
            return 1;
        }
        else
        {
            SendClientMessage(playerid,0xEB0000FF, "You already voted to heal everyone.");
        }
        return 1;
    }
    return 0;
}
Reply
#5

Quote:
Originally Posted by irinel1996
Посмотреть сообщение
HellSphinX you forgot something in your script, players can vote multiple times, use the variable PlayerHasVoted to fix that.
Oops! Fixed. You can download it from attachments.
Reply
#6

Not Work

Quote:

new HealVote = 0;
new PlayerVoted[MAX_PLAYERS];

Quote:

PlayerVoted[playerid] = 0;

Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/hl", true) == 0)
{
if(PlayerVoted[playerid] == 0)
{
HealVote += 1;
new string[64], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),"%s voted to heal everyone. (%d/7)", name, HealVote);
SendClientMessageToAll(0xEB0000FF, string);
PlayerVoted[playerid] = 1;
if(HealVote >= 7)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerHealth(i, 100);
PlayerVoted[i] = 0;
}
SendClientMessageToAll(0xEB0000FF, "Everyone has been healed.");
HealVote = 0;
}
return 1;
}
else
{
SendClientMessage(playerid,0xEB0000FF, "You already voted to heal everyone.");
}
return 1;
}
return 0;
}

Quote:

C:\Documents and Settings\789\Desktop\xtream\gamemodes\cs.pwn(1570) : error 021: symbol already defined: "OnPlayerCommandText"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#7

" HellSphinX " The File you give me have error : (file : vote.pwn)

Quote:

C:\Documents and Settings\789\My Documents\Downloads\Vote.pwn(45) : error 001: expected token: ";", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#8

Try this:

pawn Код:
#include <a_samp>
#define COLOR 0x0000FFFF

new PlayerHasVoted[MAX_PLAYERS], Votes, IsVoteRunning, VoteTimer;

public OnFilterScriptInit()
{
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    PlayerHasVoted[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(PlayerHasVoted[playerid] == 1)
    {
        PlayerHasVoted[playerid] = 0;
        Votes --;
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/hl", cmdtext, true) == 0)
    {
        if(IsVoteRunning == 1)
        {
            SendClientMessage(playerid, COLOR, "There is another vote running!");
            return 1;
        }
        else
        {
            new Name[MAX_PLAYER_NAME], string[256];
            GetPlayerName(playerid, Name, sizeof(Name));
            format(string, sizeof(string), "%s is voting to heal everyone, type /vote to vote!", Name);
            SendClientMessageToAll(COLOR, string);
            IsVoteRunning = 1;
            VoteTimer = SetTimer("VoteFunction", 60000, false); // After 1 minute
        }
        return 1;
    }
    if(strcmp("/vote", cmdtext, true) == 0)
    {
        if(IsVoteRunning == 0)
        {
            SendClientMessage(playerid, COLOR, "There is no vote running!");
        }
        else if(PlayerHasVoted[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR, "You have already voted!");
        }
        else
        {
            new Name[MAX_PLAYER_NAME], string[64];
            PlayerHasVoted[playerid] = 1;
            Votes ++;
            format(string, sizeof(string), "%s has voted (%d/7)!", Name, Votes);
            SendClientMessageToAll(COLOR, string);
            if(Votes == 7)
            {
                KillTimer(VoteTimer);
                IsVoteRunning = 0;
                Votes = 0;
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(PlayerHasVoted[i] == 1)
                    {
                        PlayerHasVoted[i] = 0;
                    }
                    SetPlayerHealth(i, 100.0);
                }
                SendClientMessageToAll(COLOR, "Votes have reached 7! Everyone's health has been restored!");
            }
        }
    }
    return 0;
}

forward VoteFunction();
public VoteFunction() // Here 1 minute has passed and vote is ending.
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerHasVoted[i] == 1)
        {
            PlayerHasVoted[i] = 0;
        }
    }
    new string[256];
    format(string, sizeof(string), "TIMEOUT! 60 seconds have passed and we got only %d vote(s)", Votes);
    SendClientMessageToAll(COLOR, string);
    IsVoteRunning = 0;
    Votes = 0;
    return 1;
}
Reply
#9

Quote:
Originally Posted by Str|ke
Посмотреть сообщение
" HellSphinX " The File you give me have error : (file : vote.pwn)
I thought you could atleast fix a simple error like this. Anyway, The person above has fixed it.
Reply
#10

its work TU, but i forget something !!!

i want make if the votes (7/7) , load new map ( for counter strike server )

under: SetPlayerHealth(i, 100.0); i want add this but i didnt know how !!!

This Is The Full Cmd To change map :

Quote:

if(strcmp(cmd, "/nextmap", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 2)
{
SetTimer("Nextmap", 2000, 0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
TogglePlayerControllable(i, 0);
}
}
}
return 1;
}

So I Want Add This To Load New Map After The Votes (7/7)

i try this but didnt work :

Quote:

if(strcmp("/vote", cmdtext, true) == 0)
{
if(IsVoteRunning == 0)
{
SendClientMessage(playerid, COLOR, "There is no vote running!");
}
else if(PlayerHasVoted[playerid] == 1)
{
SendClientMessage(playerid, COLOR, "You have already voted!");
}
else
{
new Name[MAX_PLAYER_NAME], string[64];
PlayerHasVoted[playerid] = 1;
Votes ++;
format(string, sizeof(string), "%s has voted (%d/7)!", Name, Votes);
SendClientMessageToAll(COLOR, string);
if(Votes == 7)
{
KillTimer(VoteTimer);
IsVoteRunning = 0;
Votes = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerHasVoted[i] == 1)
{
PlayerHasVoted[i] = 0;
}
SetPlayerHealth(i, 100.0); // this give all health after votes (7/7)
SetTimer("Nextmap", 2000, 0); //and this to load new map
for(new i = 0; i < MAX_PLAYERS; i++) // and this
TogglePlayerControllable(i, 0);
}

SendClientMessageToAll(COLOR, "Votes have reached 7! Everyone's health has been restored!");
}
}
}
return 0;
}

it show this error :

Quote:

C:\Documents and Settings\789\Desktop\xtream\filterscripts\vote.pwn (82) : warning 219: local variable "i" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.

Plz Help... :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)