21.10.2011, 13:39
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.
Please? Thank you.
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;
}