A few things ...
#1

SOLVED !
Reply
#2

(1) In sscanf, you have to specify a size of the string. Like this:
pawn Код:
sscanf(params, "s[24]", string
or whatever you are splitting it into.

(2 & 3) You need to make a loop that searches through all players before sending the message. I'll throw an example together real quick

pawn Код:
if (strcmp("/help", cmdtext, true) == 0)
    {
        if (gTeam[playerid] == POLICE || gTeam[playerid] == TERRORIST)
        {
            new Helpmsg[100], Name[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            GetPlayerName(playerid, Name, sizeof(Name));
            format(Helpmsg, sizeof(Helpmsg), "%s (%i) needs help! You can find him on the map!", Name, playerid);
            for(new i=0; i<MAX_PLAYERS;i++)
            {
                     if(gTeam[i] == MEDIC)
                     {
                              SendClientMessage(i, COLOR_RED, Helpmsg);
                              SetPlayerCheckpoint(i, x, y, z, 5.0);
                      }
             }
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED, "You are not a cop or a terrorist so you can't use this cmd !");
        }
        return 1;
    }
Same basic idea for #3
Reply
#3

@2@
Use:
Код:
if (strcmp("/help", cmdtext, true) == 0)
    {
        if (gTeam[playerid] == POLICE)
        {
             for(new i=0; i<MAX_PLAYERS; i++)
            if(gTeam[i] == POLICE)
            {
                     format(string, sizeof(string), "%s (%d) needs help ! You can find him on the map !"GetPlayerName(playerid), playerid);
                      SendClientMessage(i,COLOR_RED, string);
             }
            else if(gTeam[playerid] == TERRORIST)
             {
             for(new i=0; i<MAX_PLAYERS; i++)
            if(gTeam[i] == TERRORIST)
            {
                     format(string, sizeof(string), "%s (%d) needs help ! You can find him on the map !"GetPlayerName(playerid), playerid);
                      SendClientMessage(i,COLOR_RED, string);
             }
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED, "You are not a cop or a terrorist so you can't use this cmd !");
        }
        return 1;
    }
I propably left some unclosed bracers or something, but it's very late in poland and im sleepy. If theres something wrong in there, please fix it for me.
Reply
#4

pawn Код:
for(new i = 0; i < MAX_PLAYERS; ++i)
{
    if(gTeam[i] == POLICE)
    {
        // Code
    }
}
Reply
#5

Quote:
Originally Posted by Michael@Belgium
Посмотреть сообщение
hi everybody !
So i have a few problems/questions ...

(1) Account system

so i have a login/register system and everything work but in my server_log i have a warning from sscanf ...
If someone register i get this:
Код:
[21:22:23] sscanf warning: Strings without a length are deprecated, please add a destination size.
Anyone can solve the warning ?

Show us your sscanf line for the registration command

__________________________________________________ ____________________________________________

(2) Send a message to the class MEDIC

Ok, this is important to me ...
I want to make a cmd for my other classes (Terrorist & Cops), i want to use the cmd '/help'. So if a cop or a terrorist type that and press enter, then must be a SendClientMessageToAll in the Medic class...

Something like this !?

pawn Код:
if (strcmp("/help", cmdtext, true) == 0)
    {
        if (gTeam[playerid] == POLICE || gTeam[playerid] == TERRORIST)
        {
            //SendClientMessageToAll in the MEDIC class
            //SendClientMessageToAll(COLOR_RED, "<name> (<id>) needs help ! You can find him on the map !");
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED, "You are not a cop or a terrorist so you can't use this cmd !");
        }
        return 1;
    }
That should work
You see too that if someone type the cmd, then the 'helper' has to be founded on the map ! I don't have any idea to do that ! ...No clue what you mean there
__________________________________________________ ___________________________________________

(3) SendClientMessageToAll only 1 class

Yes here's the difficult part:

pawn Код:
if(strcmp("/open", cmdtext,true) == 0)
    {
        if (gTeam[playerid] == POLICE)
        {
            MoveObject(gateCop1, -1572.0594482422, 665.98590087891, 6.1875, 3);
            MoveObject(gateCop2, -1701.62109375, 702.8876953125, 23.890625, 3);
                        //SendClientMessageToAll COPS !
                        //The message should be: '<name> has opened the gates.'
        }
    }
Here you see: if a cop types '/open' then the gate's go open AND there must be an message to all COPS !
How to do this ?? :S
use this function, it will need to be modified for your use. (BELOW)
REMEMBER: I ONLY USE strcmp !

--------Can anyone solve this ?------
pawn Код:
stock CopMsg(string[])
{
    Foreach(Player, i)// ******'s foreach. Better loops
    {
        if(gTeam[i] == POLICE)
        {
            SendClientMessage(i, WHITE, string);
        }
    }
    return 1;
}
your command [pawn]
if(strcmp("/open", cmdtext,true) == 0)
{
if (gTeam[playerid] == POLICE)
{
new string[128], name[32];
MoveObject(gateCop1, -1572.0594482422, 665.98590087891, 6.1875, 3);
MoveObject(gateCop2, -1701.62109375, 702.8876953125, 23.890625, 3);
GetPlayerName(playerid, name, sizeof(name))
format(string, sizeof(string), "%s Has Opened The PD Gates!", name);
CopMsg(string);
}
}
Reply
#6

Quote:
Originally Posted by Hal
Посмотреть сообщение
pawn Код:
stock CopMsg(string[])
{
    Foreach(Player, i)// ******'s foreach. Better loops
    {
        if(gTeam[i] == POLICE)
        {
            SendClientMessage(i, WHITE, string);
        }
    }
    return 1;
}
your command
pawn Код:
if(strcmp("/open", cmdtext,true) == 0)
    {
        if (gTeam[playerid] == POLICE)
        {
            new string[128], name[32];
            MoveObject(gateCop1, -1572.0594482422, 665.98590087891, 6.1875, 3);
            MoveObject(gateCop2, -1701.62109375, 702.8876953125, 23.890625, 3);
            GetPlayerName(playerid, name, sizeof(name))
            format(string, sizeof(string), "%s Has Opened The PD Gates!", name);
            CopMsg(string);
        }
    }
ok, but here are the errors :S
Код:
C:\Users\Michael\Desktop\GTA\Eigen server\gamemodes\PAT.pwn(1261) : error 017: undefined symbol "Foreach"
C:\Users\Michael\Desktop\GTA\Eigen server\gamemodes\PAT.pwn(1263) : error 017: undefined symbol "i"
C:\Users\Michael\Desktop\GTA\Eigen server\gamemodes\PAT.pwn(1265) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Quote:
Originally Posted by randomkid88
Посмотреть сообщение
(1) In sscanf, you have to specify a size of the string. Like this:
pawn Код:
sscanf(params, "s[24]", string
or whatever you are splitting it into.

(2 & 3) You need to make a loop that searches through all players before sending the message. I'll throw an example together real quick

pawn Код:
if (strcmp("/help", cmdtext, true) == 0)
    {
        if (gTeam[playerid] == POLICE || gTeam[playerid] == TERRORIST)
        {
            new Helpmsg[100], Name[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            GetPlayerName(playerid, Name, sizeof(Name));
            format(Helpmsg, sizeof(Helpmsg), "%s (%i) needs help! You can find him on the map!", Name, playerid);
            for(new i=0; i<MAX_PLAYERS;i++)
            {
                     if(gTeam[i] == MEDIC)
                     {
                              SendClientMessage(i, COLOR_RED, Helpmsg);
                              SetPlayerCheckpoint(i, x, y, z, 5.0);
                      }
             }
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED, "You are not a cop or a terrorist so you can't use this cmd !");
        }
        return 1;
    }


Same basic idea for #3
ok i think it works, .... i don't have any errors ^^ But i don't have any medic to test if the see the message xD
ty !
Reply
#7

Anyone ?! ( o no i have made a bump ! xD)
Reply
#8

For foreach, download ******' foreach include, and add "#include <foreach>" on the top of your script.

Also it's "foreach (Player, i)", not "Foreach (Player, i)".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)