Some problems. -
Gh0sT_ - 30.07.2011
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
Re: Some problems. -
Gh0sT_ - 30.07.2011
^^^^ :<...
Re: Some problems. -
WoodPecker - 30.07.2011
Please give us more information about your problem , send here the errors please.
Re: Some problems. -
Gh0sT_ - 30.07.2011
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)
Re: Some problems. -
HyperZ - 30.07.2011
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;
}
Re: Some problems. -
Gh0sT_ - 30.07.2011
where's the difference when GetPlayerNameEx does the same?
stock GetPlayerNameEx(playerid)
{
new pName[24];
GetPlayerName(playerid, pName, 24);
return pName;
}
Re: Some problems. -
HyperZ - 30.07.2011
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?
Re: Some problems. -
CmZxC - 30.07.2011
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))
Re: Some problems. -
Gh0sT_ - 30.07.2011
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.
Re: Some problems. -
CmZxC - 30.07.2011
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;
}
Re: Some problems. -
Gh0sT_ - 30.07.2011
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.
Re: Some problems. -
CmZxC - 30.07.2011
but currently i = 0 , i guess.
well , what about
foreach(Player,MAX_PLAYERS);
( MAX_PLAYERS is defined as '500' in a_samp.inc )
Re: Some problems. -
iPLEOMAX - 30.07.2011
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;
}
Re: Some problems. -
Mean - 30.07.2011
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;
}
Re: Some problems. -
Gh0sT_ - 30.07.2011
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
.
Re: Some problems. -
Gh0sT_ - 30.07.2011
^^^^. Its weird for me, I cant understand where's the problem. Tried to "change" a bit, but no, it doesnt worked.
Re: Some problems. -
CmZxC - 30.07.2011
Quote:
pData[playerid][pFlood] = gettime() + 2;
|
what are you trying to add?
btw :
Код:
native gettime(&hour=0, &minute=0, &second=0);
Re: Some problems. -
PGTips - 30.07.2011
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
Re: Some problems. -
Gh0sT_ - 31.07.2011
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
Re: Some problems. -
Gh0sT_ - 31.07.2011
bumpp