Applying something on another player
#1

Hello.

First off, my title might not entirly fit on what I want to point out, I tried using the search function but had no luck. So go easy on me please :P
I've only got one question.

How do you apply something on another player ?
Example:

/report id
/jail id
* dLu slaps around a bit with a large trout.id
/something id

I'm asking you, how do you get the ID/name that the reporter/officer/e-thug/blabla wrote in the textbox.

I do believe that there are many ways, and for certain commands some diffrent functions or so.
But let's say for /jail id, how would you get the ID ?
I browsed the wiki, looking for something similiar to GetPlayersID or so and again not much luck.

Note: I'm not asking you to make me a /jail command, just explain me how to get the ID that the officer wrote in the text box.

I hope you understand what I mean, if not please post
~Have a nice day and thank you,

dLu
Reply
#2

Search for strtok tutorial on SA:MP Wiki.

https://sampwiki.blast.hk/wiki/Strtok
Reply
#3

Thanks !!
A bit complicated, but I'll give it a try.
Reply
#4

Quote:
Originally Posted by Ironboy500[TW]
Посмотреть сообщение
Search for strtok tutorial on SA:MP Wiki.

https://sampwiki.blast.hk/wiki/Strtok
NO!

Search for sscanf and ZCMD

pawn Код:
CMD:kill(playerid, params[])
{
    new PlayerID;
    if(sscanf(params, "r", PlayerID)) return SendClientMessage(playerid, COLOR_RED, "/Kill < PlayerID >");
    SetPlayerHealth(PlayerID, 0.0);
    return 1;
}
pawn Код:
CMD:slap(playerid, params[])
{
    new PlayerID, Float:X, Float:Y, Float:Z;
    if(sscanf(params, "r", PlayerID)) return SendClientMessage(playerid, COLOR_RED, "/Slap < PlayerID >");
    GetPlayerPos(PlayerID, X, Y, Z);
    return SetPlayerPos(PlayerID, X, Y, Z + 10);
}
You actually don't need sscanf for those. But still handy
Reply
#5

Like L3th4l said, if you are gonna use DCMD or ZCMD you don't even need SSCANF..

ZCMD Version:
pawn Код:
CMD:kill(playerid, params[])
{
    if(strlen(params) == 0) return SendClientMessage(playerid, COLOR_RED, "USSAGE: /kill [id]"); //If string lenght is 0, wich means he didn't type anything, it will return the message.
    else
    {
        SetPlayerHealth(strval(params), 0.0);//Here we convert params to an integrer, because the string 'params' is a string, and if you don't conver it, it will give error.
        return 1;
    }
}
DCMD Version
pawn Код:
dcmd_kill(playerid, params[])
{
    if(strlen(params) == 0) return SendClientMessage(playerid, COLOR_RED, "USSAGE: /kill [id]"); //If string lenght is 0, wich means he didn't type anything, it will return the message.
    else
    {
        SetPlayerHealth(strval(params), 0.0);//Here we convert params to an integrer, because the string 'params' is a string, and if you don't conver it, it will give error.
        return 1;
    }
}
Reply
#6

Sorry, but I don't use those includes(if they even are includes).
But thanks anyway!!
Reply
#7

Quote:
Originally Posted by dLu
Посмотреть сообщение
Sorry, but I don't use those includes(if they even are includes).
But thanks anyway!!
You should. DCMD is a define and is one line at the top of your script with the rest of the defines. sscanf is copy and paste at the bottom of the script, no harm.
Reply
#8

Well, I'm kinda new to this stuff and it kinda confuses me, that's why I'm doing it the other way, untill I learn the basics and then I might consider having these includes.
Thanks anyway.
Reply
#9

You should use them, if you want to do it by the classic way (strtok, cmdtext, strcmp) it will be more difficult for you..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)