SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 07/02/2014, 11:41 AM   #1
Lajko1
High-roller
 
Join Date: Oct 2008
Posts: 1,234
Reputation: 17
Default Based on player's name

How can I make if Player have [L]Name or [L]Xplayer or anything else only he will be able to drive a car and all other players with TAG [L] ?
Lajko1 is offline   Reply With Quote
Old 07/02/2014, 12:06 PM   #2
Sawalha
Gangsta
 
Join Date: Jun 2012
Location: HKJ
Posts: 510
Reputation: 62
Default Re: Based on player's name

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    new string[50];
    format(string, sizeof(string), "[L]%s", name);
    if(strcmp(name,string, false, 3)) // checking his name and [L] Tag, false is for not same size of Tag, and 3 is the lengh([ L ])
    {
        SendClientMessage(playerid, -1, "Welcome to your car");
    }
    else
    {
        RemovePlayerFromVehicle(playerid);
        SendClientMessage(playerid, -1, "You can't drive the car");
    }
    return 1;
}
not tested, but i think it will work
Sawalha is offline   Reply With Quote
Old 07/02/2014, 03:40 PM   #3
Lajko1
High-roller
 
Join Date: Oct 2008
Posts: 1,234
Reputation: 17
Default Re: Based on player's name

It's not working, it says Welcome to your car... even if I have other tag or if I'm without tag
Lajko1 is offline   Reply With Quote
Old 07/02/2014, 03:50 PM   #4
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,846
Reputation: 1399
Default Re: Based on player's name

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER)
    {
        new
            name[MAX_PLAYER_NAME];
       
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        if (!(name[0] == '[' && name[1] == 'L' && name[2] == ']'))
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, -1, "You can't drive the car");
        }
    }
    return 1;
}
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 07/02/2014, 04:12 PM   #5
Lajko1
High-roller
 
Join Date: Oct 2008
Posts: 1,234
Reputation: 17
Default Re: Based on player's name

Ty rep+
Lajko1 is offline   Reply With Quote
Old 07/02/2014, 04:18 PM   #6
Lajko1
High-roller
 
Join Date: Oct 2008
Posts: 1,234
Reputation: 17
Default Re: Based on player's name

Umm just 1 thing I used this strfind thing, and I want to make if player have [PD] tag or skin 71 he will se dispatch chat but player can see chat only if he has skinid 71

pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '-')
    {
        new string[100];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string),"::.Dispatch.:: %s: %s", sendername,text[1]);
        GetPlayerSkin(playerid);
        new cadskin = GetPlayerSkin(playerid); // cadet skin
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(strfind(sendername, "[PD]", true) == -1 || cadskin == 71)
            {
                SendClientMessage(i,0x0FFDD349,string);
            }
        }
Lajko1 is offline   Reply With Quote
Old 07/02/2014, 04:31 PM   #7
Kirollos
Gangsta
 
Kirollos's Avatar
 
Join Date: Jun 2010
Location: Cairo, Egypt
Posts: 566
Reputation: 83
Default Re: Based on player's name

pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '-')
    {
        new string[100];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string),"::.Dispatch.:: %s: %s", sendername,text[1]);
        new cadskin = GetPlayerSkin(playerid); // cadet skin
        if(strfind(sendername, "[PD]", true) != -1 || cadskin == 71)
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(!IsPlayerConnected(i)) continue;
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(i, pname, sizeof(pname));
                if(strfind(pname, "[PD]", true) != -1 || GetPlayerSkin(i) == 71)
                {
                    SendClientMessage(i,0x0FFDD349,string);
                }
            }
            return 0;
        }
    }
}
__________________
My github profile: https://github.com/Kirollos/

( ͡ ͜ʖ ͡)
Kirollos is offline   Reply With Quote
Old 07/02/2014, 06:46 PM   #8
Lajko1
High-roller
 
Join Date: Oct 2008
Posts: 1,234
Reputation: 17
Default Re: Based on player's name

Still same problem
Lajko1 is offline   Reply With Quote
Old 07/02/2014, 07:05 PM   #9
Wizz123
Big Clucker
 
Join Date: Jan 2012
Location: Wisconsin, Green Bay
Posts: 85
Reputation: 13
Default Re: Based on player's name

pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '-')
    {
        new string[100];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string),"::.Dispatch.:: %s: %s", sendername,text[1]);
        GetPlayerSkin(playerid);
        new cadskin = GetPlayerSkin(playerid); // cadet skin
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if (!(sendername[0] == '[' && sendername[1] == 'PD' && sendername[2] == ']' || cadskin == 71)
            {
                SendClientMessage(i,0x0FFDD349,string);
            }
        }
        return 1;
    }
    return 0;
}
__________________
Wizz123 is offline   Reply With Quote
Old 07/02/2014, 07:18 PM   #10
brunox
Big Clucker
 
brunox's Avatar
 
Join Date: Aug 2011
Location: Portugal
Posts: 116
Reputation: 6
Default Re: Based on player's name

pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '-')
    {
        new string[100];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string),"::.Dispatch.:: %s: %s", sendername,text[1]);
        GetPlayerSkin(playerid);
        new cadskin = GetPlayerSkin(playerid); // cadet skin
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if (!(sendername[0] == '[' && sendername[1] == 'P' && sendername[2] == 'D' && sendername[3] == ']' || cadskin == 71)
            {
                SendClientMessage(i,0x0FFDD349,string);
            }
        }
        return 1;
    }
    return 0;
}

I think it is like this Wizz
__________________

Brunox - Xitolho || Hard.
brunox 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
[PHP+DJSON] DMap 0.4 - Dynamic Website Player/Car/Obj/Shop Map(******Maps based) DracoBlue Maps 272 08/08/2014 12:57 PM
Real Market System, Player based Mr.Mafia Scripting Help 1 01/10/2012 07:10 PM
[FilterScript] SimpleDynamic MP3 Player - MySQL Based (0.3D) Rudyy Filterscripts 19 14/04/2012 09:28 AM
Change Player Skin Also Based On A Rank robert4049 Help Archive 5 20/07/2010 02:05 AM


All times are GMT. The time now is 05:33 PM.


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