targetid?
#1

Could someone explain to me what "targetid" is? And how I could define it/use it? I've used it in many of my filterscripts, but it never seems to work.

Please? Thank you.

Reply
#2

The 'targetid' is an variable, which is used to store some one elses playerid in.
Most of the ppl are using 'sscanf' for this. Little example on how to use it:
pawn Code:
YCMD:slap(playerid, params[], help)
{
    if( help ) return SendClientMessage( playerid, COLOR_BLUE, "Slapping a player" );
    if( PlayerInfo[playerid][pAdmin] > 5 )
    {
        new
            TargetID, // creating the 'TargetID'
            tReason[50];
        if( !sscanf(params, "uS(N/A)[50]", TargetID, tReason) ) // splitting the string that comes behind /slap
// example: /slap 5(TargetID) because i can slap you(tReason)
// like that, it will store '5' in TargetID, and then you can use the 'TargetID' to do something on him
        {
            if( TargetID == playerid )                      return SendClientMessage( playerid, COLOR_RED, "Cant perform this command on yourself!" );
            if( strlen( tReason) > 50 )                     return SendClientMessage( playerid, COLOR_RED, "Maximum reason size: 50" );
            if( TargetID == INVALID_PLAYER_ID )             return SendClientMessage( playerid, COLOR_RED, "Invalid playerid! Please try again" );
            new
                MyString[128],
                TargetString[128],
                Float:Pos[3];
            GetPlayerPos( TargetID, Pos[0], Pos[1], Pos[2] ); // getting the position of 'TargetID'
            SetPlayerPos( TargetID, Pos[0], Pos[1], Pos[2] + 10 ); // setting the position of 'TargetID'
            format( MyString, sizeof MyString, "You slapped %s with a rotten tuna. Reason: %s", GetName(TargetID), tReason );
            format( TargetString, sizeof TargetString, "You got slapped by %s with a rotten tuna. Reason: %s", GetName(playerid), tReason );
            SendClientMessage( playerid, COLOR_GREEN, MyString );
            SendClientMessage( TargetID, COLOR_RED, TargetString );
        }
        else
            return SendClientMessage( playerid, COLOR_YELLOW, "Usage: /setscore <TargetID> <Amount>" );
    }
    else
        return SendClientMessage( playerid, COLOR_RED, "You have to be an admin to perform this command!" );
    return 1;
}
What will ths do?
It will get the position of 'TargetID' (can be anyone, aslong as you use his playerid), and then setting it at the same position, but 10 higher.
If you still got some problems, just ask around. Im sure alot of ppl are able to help you
Reply
#3

Wow, wasn't expecting that! Thank you very much, I think I can actually work out how to incorporate it into my own script.

Thank youuuuuuuuuuuuu!



(I'll give you rep)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)