Issue with public [sscanf]
#1

I get these errors;

Quote:

C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(140 : warning 235: public function lacks forward declaration (symbol "OnPlayerNeedMedic")
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(1426) : error 029: invalid expression, assumed zero
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(1426) : warning 215: expression has no effect
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(1426) : error 001: expected token: ";", but found "if"
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(1426) : error 033: array must be indexed (variable "mDuty")

pawn Код:
new NeedMedic[MAX_PLAYERS];

public OnPlayerConnect(playerid);
{
    NeedMedic[playerid] = 0;
};

public OnPlayerNeedMedic(playerid) // line 1408
{
    new string[512];
    if(Player[playerid][Health] <= 30)
    NeedMedic[playerid] = 1;
    format(string, sizeof(string), "You have been seriously injured, %s. A by-stander has called 911, medical help is coming.", GetPlayerFirstName(playerid));
    SendClientMessage(playerid, RED, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> There has been reports of a civilian in need of urgent medical assistance!");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> The location has been automatically updated on your MDC, units please respond.");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    TogglePlayerControllable(playerid, false);
    ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,1,1,1,1,1);
    SetTimerEx("Injured", 120000, 0, "d", playerid);
    SendClientMessage(playerid, LIBLUE, "(( You are frozen for two minutes, to allow medics to get here. ))");
    {
    else if(mDuty < 1) //  // line 1426
    Hospitalized[playerid] = 1;
    }
    return 1
}

1426 is meant to check & see if there's any medics on medic duty (mDuty = 1), as that's our medic-duty function, and if not, hospitalize the player.

Here's the mDuty stuff;

pawn Код:
new mDuty[MAX_PLAYERS];

public OnPlayerConnect(playerid);
{
    mDuty[playerid] = 0;
};

// Here's the mDuty stuff from the /duty command;

if(mDuty[playerid] == 0)
{
    format(string, sizeof(string), "Paramedic Message: %s %s is now on duty.", GetRankName(playerid), RemoveUnderScore(playerid));
    FactionMessage(playerid, BLUE, string);
    mDuty[playerid] = 1;
}
Reply
#2

Add this
Код:
forward OnPlayerNeedMedic(playerid);
Show us your /duty command
Reply
#3

here you go
pawn Код:
new NeedMedic[MAX_PLAYERS];

public OnPlayerConnect(playerid);
{
    NeedMedic[playerid] = 0;
};
forward OnPlayerNeedMedic(playerid);
public OnPlayerNeedMedic(playerid) // line 1408
{
    new string[512];
    if(Player[playerid][Health] <= 30)
    NeedMedic[playerid] = 1;
    format(string, sizeof(string), "You have been seriously injured, %s. A by-stander has called 911, medical help is coming.", GetPlayerFirstName(playerid));
    SendClientMessage(playerid, RED, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> There has been reports of a civilian in need of urgent medical assistance!");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> The location has been automatically updated on your MDC, units please respond.");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    TogglePlayerControllable(playerid, false);
    ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,1,1,1,1,1);
    SetTimerEx("Injured", 120000, 0, "d", playerid);
    SendClientMessage(playerid, LIBLUE, "(( You are frozen for two minutes, to allow medics to get here. ))");
    {
    else if(mDuty != 1) //  // line 1426
    Hospitalized[playerid] = 1;
    }
    return 1
}
Quote:
Originally Posted by RenSoprano
Посмотреть сообщение
Add this
Код:
forward OnPlayerNeedMedic(playerid);
Show us your /duty command
I think mDuty < 1 is causing the error. It should be mDuty != 1
Reply
#4

There's still an issue with mDuty;

Quote:

C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(142 : error 029: invalid expression, assumed zero
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(142 : warning 215: expression has no effect
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(142 : error 001: expected token: ";", but found "if"
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(142 : error 033: array must be indexed (variable "mDuty")
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(142 : fatal error 107: too many error messages on one line

Duty command as requested;

pawn Код:
command(duty, playerid, params[])
{
    if(Player[playerid][Faction] == 1 || Player[playerid][Faction] == 2)
    {
        new string[256];
        if(isnull(params)) return SendClientMessage(playerid, WHITE, "Server: /duty [on/off]");
        {
           
            if(strmatch("on", params))
            {
                if(Player[playerid][Faction] == 1)
                {
                    if(IsPlayerInRangeOfPoint(playerid, 5.0, 233.9490,111.8341,1003.2257))
                    {
                        if(pDuty[playerid] == 0)
                        {
                            format(string, sizeof(string), "Police Message: %s %s is now on duty.", GetRankName(playerid), RemoveUnderScore(playerid));
                            FactionMessage(playerid, BLUE, string);
                            pDuty[playerid] = 1;
                        }
                        else return SendClientMessage(playerid, WHITE, "You are already on duty.");
                    }
                    else return SendClientMessage(playerid, WHITE, "You aren't near your duty switch point.");
                }
                else if(Player[playerid][Faction] == 2)
                {
                    if(IsPlayerInRangeOfPoint(playerid, 5.0, 388.29998779297,-59,923.90002441406))
                    {
                        if(mDuty[playerid] == 0)
                        {
                            format(string, sizeof(string), "Paramedic Message: %s %s is now on duty.", GetRankName(playerid), RemoveUnderScore(playerid));
                            FactionMessage(playerid, BLUE, string);
                            mDuty[playerid] = 1;
                        }
                        else return SendClientMessage(playerid, WHITE, "You are already on duty.");
                    }
                }
            }
            else if(strmatch("off", params))
            {
                if(Player[playerid][Faction] == 1)
                {
                    if(IsPlayerInRangeOfPoint(playerid, 5.0, 233.9490,111.8341,1003.2257))
                    {
                        if(pDuty[playerid] == 1)
                        {
                            format(string, sizeof(string), "Police Message: %s %s is now off duty.", GetRankName(playerid), RemoveUnderScore(playerid));
                            FactionMessage(playerid, BLUE, string);
                            pDuty[playerid] = 0;
                        }
                        else return SendClientMessage(playerid, WHITE, "You aren't on duty.");
                    }
                    else return SendClientMessage(playerid, WHITE, "You aren't near your duty switch point.");
                }
                else if(Player[playerid][Faction] == 2)
                {
                    if(IsPlayerInRangeOfPoint(playerid, 5.0, 388.29998779297,-59,923.90002441406))
                    {
                        if(mDuty[playerid] == 1)
                        {
                            format(string, sizeof(string), "Paramedic Message: %s %s is now off duty.", GetRankName(playerid), RemoveUnderScore(playerid));
                            FactionMessage(playerid, BLUE, string);
                            mDuty[playerid] = 0;
                        }
                        else return SendClientMessage(playerid, WHITE, "You aren't on duty.");
                    }
                }
            }
        }
    }
    else return SendClientMessage(playerid, WHITE, "You aren't in the correct Faction.");
    return 1;
}
Reply
#5

I wanted to ask...In your OnPlayerNeedMedic Callback
The
pawn Код:
if
is referring to player's health and the
pawn Код:
else if
is referring to a person's job.. Don't you think you need to change that?
Reply
#6

Change it to what (I'm kinda new to scripting).
Reply
#7

Can you show me or explain what does your hospitalized stock do?
Reply
#8

Got 2 errors now with this code;

pawn Код:
public OnPlayerNeedMedic(playerid)
{
    new string[512];
    if(Player[playerid][Health] <= 30)
    NeedMedic[playerid] = 1;
    format(string, sizeof(string), "You have been seriously injured, %s. A by-stander has called 911, medical help is coming.", GetPlayerFirstName(playerid));
    SendClientMessage(playerid, RED, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> There has been reports of a civilian in need of urgent medical assistance!");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> The location has been automatically updated on your MDC, units please respond.");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    TogglePlayerControllable(playerid, false);
    ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,1,1,1,1,1);
    SetTimerEx("Injured", 120000, 0, "d", playerid);
    SendClientMessage(playerid, LIBLUE, "(( You are frozen for two minutes, to allow medics to get here. ))");
    {
    if(mDuty != 1)
    Hospitalized[playerid] = 1;
    }
    return 1
}
Quote:

C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(142 : error 033: array must be indexed (variable "mDuty")
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\SCRP0.2.1.pwn(1432) : error 001: expected token: ";", but found "}"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Hospitalized sends the player to hospital when he/she is killed (health 0), it just sends a few messages to the player and sets his/her pos outside the hospital. Now, if there's no medics on duty then obviously nobody can RP with the player to /heal him, so he needs to be sent to the hospital.
Reply
#9

then i guess this code can help you
pawn Код:
public OnPlayerNeedMedic(playerid)
{
    new string[512];
    if(Player[playerid][Health] <= 30)
    NeedMedic[playerid] = 1;
    format(string, sizeof(string), "You have been seriously injured, %s. A by-stander has called 911, medical help is coming.", GetPlayerFirstName(playerid));
    SendClientMessage(playerid, RED, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> There has been reports of a civilian in need of urgent medical assistance!");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    format(string, sizeof(string), "<DISPATCH 803.71MHz> The location has been automatically updated on your MDC, units please respond.");
    SendFactionMessage(1, RADIOCHAT, string);
    SendFactionMessage(2, RADIOCHAT, string);
    TogglePlayerControllable(playerid, false);
    ApplyAnimation(playerid,"CRACK","crckdeth2",4.1,1,1,1,1,1);
    SetTimerEx("Injured", 120000, 0, "d", playerid);
    SendClientMessage(playerid, LIBLUE, "(( You are frozen for two minutes, to allow medics to get here. ))");
    {
    else if(Player[playerid][Health] == 0)
    Hospitalized[playerid] = 1;
    }
    return 1
}
This code will check that if the players health is 0, send him to hospital.
Reply
#10

But what if the players health is between 1 and 30 & there's no medics online? He'll just be sat there, frozen. That's why I inserted the function to check if there IS medics on duty, and if there is not then the player is hospitalized.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)