SA-MP Forums Archive
if any one tell me??? [+REP] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: if any one tell me??? [+REP] (/showthread.php?tid=519070)



if any one tell me??? [+REP] - PAF - 12.06.2014

Please anyone tell me that how i can script campare string fucntion


Re : if any one tell me??? [+REP] - S4t3K - 12.06.2014

There's strcmp which already exists.

But if you want to script your own, you have to do a loop through each cell of both string and comparing if the cell x from string 1 equals to the cell x from string 2.
If it does, simply use "continue;". If it doesn't, use "return false;" for example or return anything you want when the strings aren't identic.


Re: if any one tell me??? [+REP] - TakeiT - 12.06.2014

I think the easiest way is to just use strcmp for that, here's an example of one I made:

pawn Код:
CMD:key(pid, arg[])
{
    if(IsPlayerInAnyVehicle(pid))
    {
        new vehicleid = GetPlayerVehicleID(pid);
       
        new choice[5], engine, lights, alarm, doors, bonnet, boot, objective;

        GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
       
        if(sscanf(arg, "s[5]", choice)) return  SendMessage(pid, 2, "/key [off][on][acc]");
        if(!strcmp(choice, "off"))
        {



Re: Re : if any one tell me??? [+REP] - PAF - 12.06.2014

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
There's strcmp which already exists.

But if you want to script your own, you have to do a loop through each cell of both string and comparing if the cell x from string 1 equals to the cell x from string 2.
If it does, simply use "continue;". If it doesn't, use "return false;" for example or return anything you want when the strings aren't identic.
my means is tah tthe player with my community tag such as [PG]hereplayername can't enter to server without my premission or any admin premission if you know so please tell me the codes and get +REP according to title!


Re : if any one tell me??? [+REP] - S4t3K - 12.06.2014

PHP код:

stock IsPlayerNameHasPGInside
(playerid)
{
      new 
playername[MAX_PLAYER_NAME+1], teamtag[5];
      
GetPlayerName(playeridplayername25);
      
strmid(teamtagplayername04);
      if(!
strcmp(teamtag"[PG]")) return true;
      return 
false;
}
public 
OnPlayerConnect(playerid)
{
      if(
IsPlayerNameHasPGInside(playerid)) KickWithMessage(playerid, -1"You use the [PG] team tag which isn't allowed !");
      return 
1;

The function name's pretty ugly but feel free to edit it.


Re: if any one tell me??? [+REP] - TakeiT - 12.06.2014

oooohhhh, you want to use strfind. https://sampwiki.blast.hk/wiki/Strfind

check it for any special symbols, ![]{}$#@ etc.


Re: if any one tell me??? [+REP] - PAF - 12.06.2014

than when i set name the player then the players can enter


Re: if any one tell me??? [+REP] - PAF - 12.06.2014

s43tk please contact me via skype my skype name is aisam.scripter hurry