Little coding questions - For general minor queries 5

pawn Code:
SeekName(name[])
{
new pName[MAX_PLAYER_NAME];
for(new i; i < MAX_PLAYERS; i++)
{
GetPlayerName(i,pName,sizeof(pName));
if(strfind(name,pName,true) != -1) return i;
}
return INVALID_PLAYER_ID;
}
Didn't test it, but I think it'll work.
Reply

Thank you for writing it.I have tried it, it works with full name, but it doesnt with part of name.

I have found a solution, which works, its form extreme admin:

stock ReturnPlayerID(PlayerName[]) {
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) { new name[24]; GetPlayerName(i,name,24); if(strfind(name,PlayerName,true)!=-1) return i; }
return INVALID_PLAYER_ID;
}

How can i make that, if there are multiple users with the same "part of the name" (for example clan symbols), it returns an error message ?
Reply

Thank you, it works. I modified a bit, because it said unreachable code, so the last 2 lines are: else if(TotalPlayerByName == 1)return FinalID; return INVALID_PLAYER_ID;
Reply

public OnPlayerRequestSpawn(playerid)
{
new str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(dini_Exists(pfile))
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
SendMsg(playerid, BRIGHTRED, "*SERVER: THIS NAME IS REGISTERD PLEASE LOGIN /LOGIN [PASSWORD]");
format(str, sizeof(str),"", Playername(playerid));
SendMsg(playerid, YELLOW, "*SERVER: Registered Username:%s ");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
}
else
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
format(str, sizeof(str),"", Playername(playerid));
SendMsg(playerid, BRIGHTRED, "*SERVER: You Are Not Registered Please Register Using /Register [PASSWORD]!");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
return 0;
}

i just want it to be if the person isnt registered

no function like dini_doesnot_exist<.<?
Reply

pawn Code:
public OnPlayerRequestSpawn(playerid)
{
    new str[128];
    format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
    if(!dini_Exists(pfile))
    {
        SendClientMessage(playerid, BRIGHTRED, "");
        SendClientMessage(playerid, BRIGHTRED, "");
        SendClientMessage(playerid, BRIGHTRED, "");
        SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
        format(str, sizeof(str),"", Playername(playerid));
        SendMsg(playerid, BRIGHTRED, "*SERVER: You Are Not Registered Please Register Using /Register [PASSWORD]!");
        SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
        return 0;
    }
    return 1;
}
Reply

this crashes the server when i try to spawn.

btw how did you get your thing into a pawn code? idk how with the new forum

public OnPlayerRequestSpawn(playerid)
{
new str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(!dini_Exists(pfile))
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
format(str, sizeof(str),"", Playername(playerid));
SendMsg(playerid, BRIGHTRED, "*SERVER: You Are Not Registered Please Register Using /Register [PASSWORD]!");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
return 0;
}
if(IsLogged[playerid] == 0)
{
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
SendMsg(playerid, BRIGHTRED, "*SERVER: THIS NAME IS REGISTERD PLEASE LOGIN /LOGIN [PASSWORD]");
format(str, sizeof(str),"", Playername(playerid));
SendMsg(playerid, YELLOW, "*SERVER: Registered Username:%s ");
SendClientMessage(playerid, BRIGHTRED, "--------------------------------------------");
return 0;
}
return 1;
}
Reply

Hey how can I put a limit so that in one team only one player can spawn but in the other teams more than 1 people can spawn ?
Reply

Quote:
Originally Posted by [XST]O_x
View Post
I have a question.
If I'd do:
pawn Code:
new Float:ax,Float:ay,Float:az,id; GetPlayerPos(id,ax,ay,az);
    //arrest command continues from here..

    if(IsPlayerInRangeOfPoint(playerid,10,ax,ay,az);
Or:
pawn Code:
if(GetDistanceBetweenPlayers(playerid,id) == 10)
Will it affect the same?
No it won't. The first code checks if the player is within 10.0 float radius to another player (well, to a point, but the point is set to another player's coordinates) and the second one checks if the player is EXACTLY 10.0 floats away from another player.

These are the same:
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
if(GetDistanceBetweenPlayers(playerid, id) <= 10.0)
If you had typo in your code, sorry for being a smart ass.
Reply

nevermind
Reply

Quote:
Originally Posted by Finn
View Post
Bla
Oh okay =P

The responses were kind of late so I used GetDistanceBetweenPlayers anyway ^_^

Thanks though,it's always good to know new things.
Reply

Hey how can I put a limit so that in one team only one player can spawn but in the other teams more than 1 people can spawn ?
Reply

I am looking for a code, which converts a number like this:

12000 -> 12 000 or 12.000
(if the number is bigger, then like this: 123456789 -> 123.456.789)
Reply

Zeli; there is probably a more efficient way of doing this but this is what I came up with:

pawn Code:
ConvertNumber(number)
{
    new num[16], count;
    valstr(num, number);
   
    for(new i = strlen(num); i > 0; i--)
    {
        if(count == 3)
        {
            count = 0;
            strins(num, ".",  i);
        }

        count++;
    }
   
    return num;
}
Reply

I tried it, it works fine.
Thank you very much for your help!! Very useful stuff for me.
Reply

I have a slight problem here.

pawn Code:
SetPlayerWantedLevel(playerid, floatround(level/2, floatround_ceil));
When I input 'level' as being 5, it rounds to 2 and not to 3 which is supposed to be.
Or am I missing something here?
Reply

Quote:
Originally Posted by Vince
View Post
I have a slight problem here.

pawn Code:
SetPlayerWantedLevel(playerid, floatround(level/2, floatround_ceil));
When I input 'level' as being 5, it rounds to 2 and not to 3 which is supposed to be.
Or am I missing something here?
Int/Int = Int

So,
5/2 = 2
Ceiling of 2 = 2.

You need to perform the division using floats, try this:
SetPlayerWantedLevel(playerid, floatround(floatval(level)/2.0, floatround_ceil));

(Make sure floatval's the right function, I can't remember the exact name but I'm pretty sure that's the one that returns a float from an int)
Reply

you stole it from here right? ^

you cant make code knowing you dont have the includes..

anyway,

download dutils from dracoblue.net

and put it in pawno>includes folder, then recompile
Reply

Quote:
Originally Posted by »Wоllstah™«
View Post
you stole it from here right? ^

you cant make code knowing you dont have the includes..

anyway,

download dutils from dracoblue.net

and put it in pawno>includes folder, then recompile
So I downloaded it from dracoblue.net and now I have error:
Code:
C:\Documents and Settings\Justas\Desktop\samp\pawno\include\dudb.inc(26) : fatal error 100: cannot read from file: "dini"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply

download dini too, from the same website
Reply

You need to include dutils or get the dutils.inc
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)