Need help with player name
#1

I'm trying to make a /eject <player name> command but I don't know how to make the code for it, I don't want to 'GetPlayerName', I want the player name that have been stated ejected from a car. Is it the same as the 'GetPlayerName' script

Sorry for my bad English
Reply
#2

pawn Код:
if(strcmp(cmd, "/eject", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new State;
            if(IsPlayerInAnyVehicle(playerid))
            {
                State=GetPlayerState(playerid);
                if(State!=PLAYER_STATE_DRIVER)
                {
                    SCM(playerid,COLOR_GREY,"   You can only eject people as the driver !");
                    return 1;
                }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SCM(playerid, COLOR_GRAD2, "USAGE: /eject [playerid/PartOfName]");
                    return 1;
                }
                new playa;
                playa = ReturnUser(tmp);
                new test;
                test = GetPlayerVehicleID(playerid);
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        if(playa == playerid) { SCM(playerid, COLOR_GREY, "You cannot Eject yourself!"); return 1; }
                        if(IsPlayerInVehicle(playa,test))
                        {
                            new PName[MAX_PLAYER_NAME];
                            GetPlayerName(playerid,PName,sizeof(PName));
                            GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                            format(string, sizeof(string), "* You have thrown %s out of the car!", giveplayer);
                            SCM(playerid, COLOR_LIGHTBLUE, string);
                            format(string, sizeof(string), "* You have been thrown out the car by %s !", PName);
                            SCM(playa, COLOR_LIGHTBLUE, string);
                            RemovePlayerFromVehicle(playa);
                        }
                        else
                        {
                            SCM(playerid, COLOR_GREY, "   That player is not in your Car !");
                            return 1;
                        }
                    }
                }
                else
                {
                    SCM(playerid, COLOR_GREY, " Invalid ID/Name!");
                }
            }
            else
            {
                SCM(playerid, COLOR_GREY, "   You need to be in a Vehicle to use this !");
            }
        }
        return 1;
    }
Reply
#3

Here's the command using ZCMD and sscanf! You require them in your script to use this command!

pawn Код:
COMMAND:eject(playerid, params[])
{
    if (IsPlayerConnected(playerid))
    {
        new player,string[80];
        if(sscanf(params,"u",player)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /eject [playerid/partofname]]");
        if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Invalid Player. That Player is not connected to the server.");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to be in a vehicle to use this command.");
        if(!IsPlayerInAnyVehicle(player)) return SendClientMessage(playerid, COLOR_GREY, "That player is not in any vehicle.");
        new vid = GetPlayerVehicleID(playerid),pid = GetPlayerVehicleID(player),pname[MAX_PLAYERS],plname[MAX_PLAYERS];
        if(vid != pid) return SendClientMessage(playerid, COLOR_GREY, "That player needs to be in your vehicle to eject them.");
        GetPlayerName(playerid, pname, sizeof(pname)),GetPlayerName(player, plname, sizeof(plname));
        format(string, sizeof(string), "* You have been ejected by %s from their vehicle.", pname);
        SendClientMessage(player,COLOR_YELLOW,string);
        format(string, sizeof(string), "* You have ejected %s from your vehicle.", plname);
        SendClientMessage(playerid,COLOR_YELLOW,string);
    }
    return 1;
}
Reply
#4

Thanks for all the help guys
Reply
#5

BTW I downloaded sscanf, I have 3 files pawno, plugins and sscanf. Where do I put sscanf file? If possible, may I know where to place Whirlpool files too? Thanks
Reply
#6

  • sscanf folder should be inside your server folder!
  • sscanf2.inc should be in /pawno/includes folder of your server folder.
  • sscanf.dll and sscanf.so should be in plugins/ folder. If plugins folder is not in your server folder then create it and paste this file there.
Reply
#7

Thanks! do you know where to place Whirlpool?
Reply
#8

Quote:
Originally Posted by SlonCHL
Посмотреть сообщение
Thanks! do you know where to place Whirlpool?
Same for every include and plugins!!

Plugin (.dll & .so) goes into plugins folder and .inc goes into /pawno/includes folder in your server folder!
Reply
#9

Ok thanks again
Reply
#10

C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(203) : error 017: undefined symbol "eject"
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(204) : warning 217: loose indentation
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(20 : error 017: undefined symbol "params"
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(223) : warning 225: unreachable code
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(223) : warning 217: loose indentation
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(65) : warning 204: symbol is assigned a value that is never used: "tmp"
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(203) : warning 203: symbol is never used: "COMMAND"
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(297) : warning 217: loose indentation
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(307) : warning 217: loose indentation
C:\xampp\htdocs\samp\filterscripts\car_buyer_scrip t.pwn(30 : warning 217: loose indentation
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)