SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 06/07/2011, 12:11 PM   #1
Harry_Sandhu
Huge Clucker
 
Join Date: Jun 2011
Posts: 217
Reputation: 0
Default Show only first name

Is there any script so it shows the Players First name only and not the Lastname?

If yes then can you tell me how it can be?
Harry_Sandhu is offline  
Old 06/07/2011, 12:23 PM   #2
SwatOwner
Big Clucker
 
SwatOwner's Avatar
 
Join Date: Apr 2011
Posts: 86
Reputation: 4
Default Re: Show only first name

you need a script or code huh ?

if only FirstName only
just disable Firstname_Lastname in your script./
__________________
Best Public Enemy Pen 1

Join us Cmon !

Its Public Enemy Fixed by Us Join us !! For Real Fun


SwatOwner is offline  
Old 06/07/2011, 12:39 PM   #3
Harry_Sandhu
Huge Clucker
 
Join Date: Jun 2011
Posts: 217
Reputation: 0
Default Re: Show only first name

I dont want to Disable it i want the Script.
I dont want to Disable on everything. I want to Disable it on OnPlayerConnect. So the message will come Welcome to my server Firstname
Harry_Sandhu is offline  
Old 06/07/2011, 12:59 PM   #4
Calgon
Godfather
 
Join Date: Jan 2009
Location: GRATE DANE
Posts: 6,179
Reputation: 819
Default Re: Show only first name

I just made this function for you, though I haven't had a chance to properly test it.

pawn Code:
stock getFirstName(szPlayerName[]) {
    new
        _tmpSzPlayerName[MAX_PLAYER_NAME],
        iCh = strfind(szPlayerName, "_", true);
       
    if(iCh != -1) {
        strcat(_tmpSzPlayerName, szPlayerName, MAX_PLAYER_NAME);
        strdel(_tmpSzPlayerName, iCh, strlen(szPlayerName));
    } else {
        format(_tmpSzPlayerName, sizeof(_tmpSzPlayerName), "Nameless");
    }

    return _tmpSzPlayerName;
}

This will only get the name before the first underscore.

Usage:
pawn Code:
new szName[MAX_PLAYER_NAME], szMessage[128];
GetPlayerName(playerid, szName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "Hi, %s. How are you?", getFirstName(szName));
__________________
ReAp if i HElp

return 1 fix al

Quote:
(10:27:18 PM) dugi: hello is this the police?
(10:27:25 PM) dugi: Calgon is being mean
(10:27:31 PM) dugi: arrest him pls

Last edited by Calgon; 06/07/2011 at 02:57 PM.
Calgon is offline  
Old 06/07/2011, 02:43 PM   #5
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 646
Reputation: 32
Default Re: Show only first name

pawn Code:
stock GetFirstName(playerid){
 new PlayerName[128], Split[3][128];
 GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
 split(PlayerName, Split, '_');
 return Split[0];
}
__________________
Code:
• [GameMode]Unfinished roleplay script [Dynamic]
• [GameMode]LostHeaven: Roleplay (SW-RP Edit)
• [FilterScript]Stopwatch Filterscript
• [FilterScript] CreateVehicle Organized IDs
• [Function] GetVehicleTrailerPos
• [Tutorial] MySQL Threading
• [Include] vStreamex Vehicle Streamer
CoaPsyFactor is offline  
Old 06/07/2011, 02:44 PM   #6
Calgon
Godfather
 
Join Date: Jan 2009
Location: GRATE DANE
Posts: 6,179
Reputation: 819
Default Re: Show only first name

You need the split function for that code, CoaPsyFactor.
__________________
ReAp if i HElp

return 1 fix al

Quote:
(10:27:18 PM) dugi: hello is this the police?
(10:27:25 PM) dugi: Calgon is being mean
(10:27:31 PM) dugi: arrest him pls
Calgon is offline  
Old 06/07/2011, 02:46 PM   #7
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 646
Reputation: 32
Default Re: Show only first name

pawn Code:
stock split(const strsrc[], strdest[][], delimiter)
{
    GetPlayerName(
    new i, li;
    new aNum;
    new len;
    while(i <= strlen(strsrc))
    {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
            len = strmid(strdest[aNum], strsrc, li, i, 128);
            strdest[aNum][len] = 0;
            li = i+1;
            aNum++;
        }
        i++;
    }
    return 1;
}
__________________
Code:
• [GameMode]Unfinished roleplay script [Dynamic]
• [GameMode]LostHeaven: Roleplay (SW-RP Edit)
• [FilterScript]Stopwatch Filterscript
• [FilterScript] CreateVehicle Organized IDs
• [Function] GetVehicleTrailerPos
• [Tutorial] MySQL Threading
• [Include] vStreamex Vehicle Streamer
CoaPsyFactor is offline  
Old 06/07/2011, 02:56 PM   #8
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 3,308
Reputation: 337
Default AW: Show only first name

You just could do it like that

pawn Code:
stock getFirstName(name[]) {
    new
        dest[MAX_PLAYER_NAME];
    dest[1] = strfind(name, "_", false);
    if(dest[1] != -1) {
        strcat(dest, name, dest[1]);
    } else {
        strcat(dest, name, sizeof dest);
    }
    return dest;
}
__________________


Nero_3D is offline  
Old 06/07/2011, 02:59 PM   #9
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 646
Reputation: 32
Default Re: Show only first name

as you wish
__________________
Code:
• [GameMode]Unfinished roleplay script [Dynamic]
• [GameMode]LostHeaven: Roleplay (SW-RP Edit)
• [FilterScript]Stopwatch Filterscript
• [FilterScript] CreateVehicle Organized IDs
• [Function] GetVehicleTrailerPos
• [Tutorial] MySQL Threading
• [Include] vStreamex Vehicle Streamer
CoaPsyFactor is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Doesn't show the name. Scriptissue Help Archive 3 10/10/2010 02:59 PM
How to show the bag? mirkoiz Help Archive 26 25/05/2010 07:53 PM
Show off Ravia_Devaia Archive 14 18/04/2010 11:51 AM
Just show me the way to do it pierhs Help Archive 7 22/07/2009 09:48 PM


All times are GMT. The time now is 01:04 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.