Detecting name wont work :/
#1

pawn Код:
public OnPlayerConnect(playerid)
{
    PlayerSpawned[playerid] = 1;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PlayerSpawned[playerid] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
   new name[256];
   new string[128];
   GetPlayerName(playerid, name, sizeof(name));
   if(PlayerSpawned[playerid] == 1)
   {
       if(!strcmp(name,"[COD]Alex", true))
       {
           format(string, sizeof(string), "~r~Owner~w~ %s~b~(%d)~r~ has joined the server.", name,playerid);
           GameTextForAll(string, 4000, 6);
       }
 
    }
    return 1;
}
Reply
#2

• It's not a good idea to place your code when he spawn, that mean each time he dead then spawn, the message will be sent.
• Why you use GameText, you can simply use SendClientMessageToAll.
Reply
#3

SendClientMessageToAll would be better,

if it is GameTextForAll it will disturb another Player, so try using SendClientMessageToAll,

and it must be in OnPlayerConnect not OnPlayerSpawn because if it is OnPlayerSpawn,

the Message will send after you Spawned,


pawn Код:
public OnPlayerConnect(playerid)
{
   new name[MAX_PLAYER_NAME];
   new string[1200];
   GetPlayerName(playerid, name, sizeof(name));
   if(PlayerLogged[playerid] == 1)
   {
       if(!strcmp(name,"[COD]Alex", true))
       {
           format(string, sizeof(string), "{FF0000}Owner {EEEEEE}%s (ID: {FF0000}%d{EEEEEE}) has joined the server.", name, playerid);
           SendClientMessageToAll(-1, string);
       }
 
    }
    return 1;
}
Reply
#4

Thats why i have a variable, under on player connect, so everytime i spawn it doesnt come up.....
Reply
#5

But it would be better if it is on OnPlayerConnect, because it will show the Message(s) when you joined.

and if it is on OnPlayerSpawn, it will show the Message(s) when you got spawned.
Reply
#6

I saw your variable but I've never saw when you turn it to 0 when he died but when he disconnect you add it.
Reply
#7

Either way, wont appear the message :/
Reply
#8

Are you sure you are actually connecting with [COD]Alex? (Sounds stupid to ask but it happens xD)

Doesn't look like theres anything wrong with your code (besides the fact that the name variable is 256 instead of 24/MAX_PLAYER_NAME :P).

I threw it into my script and it worked perfectly. Are you lagging or anything when you spawn, and you actually don't see it in time?
Reply
#9

pawn Код:
if(!strcmp(name(playerid),"[COD]Alex",true)) // for me it's :
// if he logging to the server and he don't have [COD]Alex (because of !strcmp)
{ //
    // send the message
    SendClientMessageToAll(COLOR,"blabla"); //
    return 1; //
} //

// try like this

if(strcmp(name,"[COD]Alex",true)) // for me it's :
// if he logging to the server and he have [COD]Alex (because of strcmp)
{ //
    // send the message
    SendClientMessageToAll(COLOR,"blabla"); //
    return 1; //
}
else // is name is not [COD]Alex
{ //
    SendClientMessageToAll(COLOR, "blabla"); //
    return 1; //
}//
correct me If I am wrong
Reply
#10

Quote:
Originally Posted by Matnix
Посмотреть сообщение
pawn Код:
if(!strcmp(name(playerid),"[COD]Alex",true)) // for me it's :
// if he logging to the server and he don't have [COD]Alex (because of !strcmp)
{ //
    // send the message
    SendClientMessageToAll(COLOR,"blabla"); //
    return 1; //
} //

// try like this

if(strcmp(name,"[COD]Alex",true)) // for me it's :
// if he logging to the server and he have [COD]Alex (because of strcmp)
{ //
    // send the message
    SendClientMessageToAll(COLOR,"blabla"); //
    return 1; //
}
else // is name is not [COD]Alex
{ //
    SendClientMessageToAll(COLOR, "blabla"); //
    return 1; //
}//
correct me If I am wrong
you are wrong, if you can't compare two things then they are the same and strcmp will return 0

Quote:
Originally Posted by Alex_Obando
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid)
{
   printf("OPS called %d",playerid);
   new name[256];
   new string[128];
   GetPlayerName(playerid, name, sizeof(name));
   if(PlayerSpawned[playerid] == 1)
   {
           printf("PlayerSpawned is equal to 1 %s",name);
       if(!strcmp(name,"[COD]Alex", true))
       {
           format(string, sizeof(string), "~r~Owner~w~ %s~b~(%d)~r~ has joined the server.", name,playerid);
               printf("strcmp check passed %s",string);
           GameTextForAll(string, 4000, 6);
       }
 
    }
    return 1;
}
you should add some print messages so you know exactly where it's failing
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)