SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 22/03/2020, 03:58 PM   #1
PowerF
Huge Clucker
 
PowerF's Avatar
 
Join Date: May 2014
Posts: 419
Reputation: 3
Default Check if player has specified word in their name

I want to check if player has specified word in their name
for example i want to check if player has 'SAMP_' in their nickname. how do i do it?
PowerF is offline   Reply With Quote
Old 22/03/2020, 04:07 PM   #2
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,000
Reputation: 92
Default Re: Check if player has specified word in their name

https://wiki.sa-mp.com/wiki/Strcmp
__________________
Coming soon (6-1-2020):

Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Official Live Beta Release Date: 1st of June, 2020
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 22/03/2020, 04:08 PM   #3
Kasichok
Big Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 97
Reputation: 35
Default Re: Check if player has specified word in their name

PHP Code:
new name[24];
GetPlayerName(playeridname24);
if(
strfind(name"_") != -1)
{
    
//found _

__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 22/03/2020, 04:12 PM   #4
PowerF
Huge Clucker
 
PowerF's Avatar
 
Join Date: May 2014
Posts: 419
Reputation: 3
Default Re: Check if player has specified word in their name

Quote:
Originally Posted by jasperschellekens View Post
It only detects that string only, it doesn't detect random numbers or words after SAMP_
PowerF is offline   Reply With Quote
Old 22/03/2020, 05:11 PM   #5
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 625
Reputation: 54
Default Re: Check if player has specified word in their name

What do you want to detect/find "SAMP_" or "SAMP_(random numbers or words)" if you want to detect the former see post#2 if you want to detect the latter you have to use regex (there should be other solution but idk right now).
__________________
coool is offline   Reply With Quote
Old 25/03/2020, 02:29 AM   #6
Nuginity
Big Clucker
 
Nuginity's Avatar
 
Join Date: Feb 2020
Location: Indonesia (Jakarta)
Posts: 61
Reputation: 2
Default Re: Check if player has specified word in their name

so you need a number? sure

HTML Code:
stock namecheck(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(strfind(pname,"[",true) != (-1)) return 0;
    else if(strfind(pname,"]",true) != (-1)) return 0;
    else if(strfind(pname,"$",true) != (-1)) return 0;
    else if(strfind(pname,"(",true) != (-1)) return 0;
    else if(strfind(pname,")",true) != (-1)) return 0;
    else if(strfind(pname,"=",true) != (-1)) return 0;
    else if(strfind(pname,"@",true) != (-1)) return 0;
    else if(strfind(pname,"0",true) != (-1)) return 0;
    else if(strfind(pname,"1",true) != (-1)) return 0;
    else if(strfind(pname,"2",true) != (-1)) return 0;
    else if(strfind(pname,"3",true) != (-1)) return 0;
    else if(strfind(pname,"4",true) != (-1)) return 0;
    else if(strfind(pname,"5",true) != (-1)) return 0;
    else if(strfind(pname,"6",true) != (-1)) return 0;
    else if(strfind(pname,"7",true) != (-1)) return 0;
    else if(strfind(pname,"8",true) != (-1)) return 0;
    else if(strfind(pname,"9",true) != (-1)) return 0;
    return 1;
}
Then put the stock in to OnPlayerConnect function
HTML Code:
OnPlayerConnect(playerid)
{
    if(!namecheck(playerid))
          {
           //Your code's when the player has that characters on their names
           }
    return 1;
}
Nuginity is offline   Reply With Quote
Reply

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
How to check if a player is facing another player GameOvr Scripting Help 2 12/12/2018 11:07 AM
Word under player Martin4 Scripting Help 4 14/12/2016 06:20 PM
Check if player is standing behind other player Riddick94 Scripting Help 3 15/08/2015 07:28 PM
Put a word above player's head Sn4ke Help Archive 4 12/03/2011 11:28 AM
How do I check if a string Equals a certain word? ViperSniper Help Archive 5 19/01/2011 05:35 PM


All times are GMT. The time now is 04:22 PM.


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