Some problems.
#1

1. Why this function doesnt work? It returns nothing.

pawn Код:
stock GetPlayerIDFromName(vardas[])
{
    foreach(Player, i)
    {
        if(strcmp(GetPlayerNameEx(i), vardas, false, strlen(vardas))) return i;
    }
    return INVALID_PLAYER_ID;
}
2. Why this doesnt work? I want to make that I can use function only in some position or when player is on boat, but I can use it anywhere:

pawn Код:
if(IsPlayerOnBoat(playerid) || IsPlayerInRangeOfPoint(playerid, 5.0, -2230.2192, 2438.6248, 2.4934) || IsPlayerInRangeOfPoint(playerid, 5.0, -2214.2671, 2423.2520, 2.4970) || IsPlayerInRangeOfPoint(playerid, 5.0, -2249.8706, 2418.3701, 2.4971) || IsPlayerInRangeOfPoint(playerid, 5.0, -2234.0686, 2402.3960, 2.4899))
        {
            if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, -1, "{FFFFFF}[ {FF0000}KLAIDA {FFFFFF}]: Jыs turite bыti ant {33AA33}kojш!");
<..>
THANKS
Reply
#2

^^^^ :<...
Reply
#3

Please give us more information about your problem , send here the errors please.
Reply
#4

If there would be errors, then I would cant test it... I dont get any errors/warning or smth, its just dont work as it should. (there enought info I think in first post)
Reply
#5

pawn Код:
stock GetPlayerIDFromName(vardas[])
{
    foreach(Player, i)
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(i, pName, sizeof(pName));
        if(strcmp(pName, vardas, true, strlen(vardas)) == 0)
        {
            return i;
        }
    }
    return INVALID_PLAYER_ID;
}
Reply
#6

where's the difference when GetPlayerNameEx does the same?

stock GetPlayerNameEx(playerid)
{
new pName[24];
GetPlayerName(playerid, pName, 24);
return pName;
}
Reply
#7

Quote:
Originally Posted by Gh0sT_
Посмотреть сообщение
where's the difference when GetPlayerNameEx does the same?

stock GetPlayerNameEx(playerid)
{
new pName[24];
GetPlayerName(playerid, pName, 24);
return pName;
}
Is my code working or not?
Reply
#8

2. You're using like this : if(ON BOAT -OR- IN POS -OR- etc etc)
So when you're on boat, it's returning it, even if your in a plane at that location, its returning the message and the functions you have after that message.

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0, -2230.2192, 2438.6248, 2.4934) || IsPlayerInRangeOfPoint(playerid, 5.0, -2214.2671, 2423.2520, 2.4970) || IsPlayerInRangeOfPoint(playerid, 5.0, -2249.8706, 2418.3701, 2.4971) || IsPlayerInRangeOfPoint(playerid, 5.0, -2234.0686, 2402.3960, 2.4899))
{
    if(IsPlayerOnBoat(playerid))
Reply
#9

Isnt your code will check IsPlayerOnBoat first? This will return 0 (IsPlayerOnBoat) when I will be in any place where I can fish. Im making fish system, and you can fish in boats and some places.
Reply
#10

switched the pos check to 1st and vehicle check to 2nd

btw at #1 you don't have the "i" defined...

pawn Код:
stock GetPlayerIDFromName(vardas[])
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        foreach(Player, i)
        {
           if(strcmp(GetPlayerNameEx(i), vardas, false, strlen(vardas))) return i;
        }
    }
    return INVALID_PLAYER_ID;
}
Reply
#11

Quote:
Originally Posted by CmZxC
Посмотреть сообщение
switched the pos check to 1st and vehicle check to 2nd

btw at #1 you don't have the "i" defined...

pawn Код:
stock GetPlayerIDFromName(vardas[])
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        foreach(Player, i)
        {
           if(strcmp(GetPlayerNameEx(i), vardas, false, strlen(vardas))) return i;
        }
    }
    return INVALID_PLAYER_ID;
}
I have, im using foreach for better loops.
Reply
#12

but currently i = 0 , i guess.
well , what about
foreach(Player,MAX_PLAYERS);
( MAX_PLAYERS is defined as '500' in a_samp.inc )
Reply
#13

I used this before i started using sscanf.. ^^
pawn Код:
stock GetIDFromName(playername[]) // © by iPLEOMAX
{
    foreach(Player, i)
    {
        new pname[MAX_PLAYER_NAME];
        GetPlayerName(i,pname,MAX_PLAYER_NAME);
        if(strfind(pname,playername,true) != -1 && strlen(playername) != 0) { return i; }
    }
    if(strfind(playername, "0",true) != -1 && strlen(playername) <= 1) return 0;
    if(strval(playername) > 0 && strval(playername) < MAX_PLAYERS) return strval(playername);
    return -1;
}
Both IDs/part of names work.

Example:
pawn Код:
CMD:test( playerid, params[] )
{
    new partofname[24];
    if (sscanf (params, "s[24]", partofname) ) return SendClientMessage( playerid, -1, "Usage: /test [part of name]" );
   
    SendClientMessage( GetIDFromName(partofname), -1, "I found your ID!" );
   
    return true;
}
Reply
#14

Why don't you just use the "GetPlayerID( const playername[ ], partofname = 0 )" native?

Part of name is also toggleable...

https://sampwiki.blast.hk/wiki/GetPlayerID
So I do:
pawn Код:
CMD:sendmeanamessage( playerid, params[ ] ) {
    new meanid = GetPlayerID( "Mean" );
    if( meanid == -1 )
        return SendClientMessage( playerid, -1, "Mean is not connected! " );
    SendClientMessage( meanid, -1, "You got a message! " );
    return 1;
}
Reply
#15

Somewhere I need it for sending mysql queries, but anyways thanks.

Now another problem:

After OnPlayerText, OnPlayerCommandReceived I have

if(pData[playerid][pFlood] != 0 && pData[playerid][pFlood] < gettime()) return 0;

Then, after player sends a messages, or uses command:

pData[playerid][pFlood] = gettime() + 2;

And it likes "freezes" my server when sending messages/using commands
.
Reply
#16

^^^^. Its weird for me, I cant understand where's the problem. Tried to "change" a bit, but no, it doesnt worked.
Reply
#17

Quote:

pData[playerid][pFlood] = gettime() + 2;

what are you trying to add?

btw :

Код:
native gettime(&hour=0, &minute=0, &second=0);
Reply
#18

pawn Код:
stock GetPlayerIdFromName(playername[])
{
  for(new i = 0; i <= MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
  {
      new playername2[MAX_PLAYER_NAME];
      GetPlayerName(i, playername2, sizeof(playername2));
      if(strcmp(playername2, playername, true, strlen(playername)) == 0)
      {
        return i;
      }
    }
  }
  return INVALID_PLAYER_ID;}

SOrry for jumbled code i coded it on the box
Reply
#19

Quote:
Originally Posted by CmZxC
Посмотреть сообщение
what are you trying to add?

btw :

Код:
native gettime(&hour=0, &minute=0, &second=0);
gettime without params(like now - gettime() ) returns unix timestamp. so, I want to make an antispam without timers, blablalbal
Reply
#20

bumpp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)