[Help] About Making Commands "TMP"
#1

Hello, well im looking for Help from someone that can teach me TMP or how to do the /xx zzzzz Commands style
Like When player dont type it good, Correct usage is /xx zzzzz
Anyway i know that have relation with Tmp so could anyone explain me please?
Reply
#2

Thanks Lot Bro, but would you give me an example of

/getweapon [Name Of weapon]
A Full code with some explanations if you can please, using strcmp and SScanf
If you couldnt be busy, may you give me an example of /makeadmin [Playerid] too?
Thanks anyway for teh previous explanation
Reply
#3

you will need strtok include for this command...the command is /giveweapon [weaponid] [ammo])
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
new 
idx;
new 
cmd[256];
cmd strtok(cmdtextidx);
if(
strcmp(cmd"/giveweapon"true) == 0) {
  new 
tmp[256],tmp2[256],tmp3[256];
  
tmp strtok(cmdtextidx);
  
tmp2 strtok(cmdtextidx);
  
tmp3 strtok(cmdtextidx);
    if(!
strlen(tmp)) {
  
SendClientMessage(playeridCOLOUR_ORANGE"Usage : /giveweapon [playerid] [weaponid] [amount]");
  return 
1;
  }
  if(!
strlen(tmp2)) {
  
SendClientMessage(playeridCOLOUR_ORANGE"Usage : /giveweapon [playerid] [weaponid] [amount]");
  return 
1;
  }
  if(!
strlen(tmp3)) {
  
SendClientMessage(playeridCOLOUR_ORANGE"Usage : /giveweapon [playerid] [weaponid] [amount]");
  return 
1;
  }
  new 
victimweaponidammo;
  
victim strval(tmp);
  
weaponid strval(tmp2);
  
ammo strval(tmp3);
  new 
string[128];
  new 
playername[MAX_PLAYER_NAME];
  
GetPlayerName(playeridplayernamesizeof(playername));
  new 
playername2[MAX_PLAYER_NAME];
  
GetPlayerName(victimplayername2sizeof(playername2));
  
  
format(stringsizeof(string), "The admin %s gave you a weapon."playername);
  
SendClientMessage(victimCOLOUR_YELLOWstring);
GivePlayerWeapon(victimweaponidammo);
format(stringsizeof(string), "you gave %s a weapon."playername2);
  
SendClientMessage(playeridCOLOUR_YELLOWstring);
  return 
1;
  } 
Reply
#4

Thanks Lot Bro!!
Reply
#5

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
@omer5198: Read what I said before:
If you are using STRTOK then stop using it. It is slow, out of date and everyone says it's bad so I have no idea why it's still on SA:MP Wiki.


Ok, a getweapon command is pretty much the same as what I wrote earlier.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[30], params[100];
    sscanf(cmdtext, "s[30]s[100]", cmd, params);
   
    if(!strcmp(cmd, "/getweapon"))
    {
        new id = strval(params);
// Right here the ID doesn't just have to be a playerid
// remember pretty much everything in SA:MP is represented by numbers, playerids, cars, weapons etc
// This basic command is pretty much: '/command <number>' [without the '<' and '>' obviously]
// So 'params' is just whatever text the player types after a space in the command.
// And in this example we use 'strval' to convert that string to a number so it can be used in functions that require 'ID' numbers
// Such as player ids, weapon models, vehicle models, any data that is represented by a number in function parameters.


// So you now have your 'id' variable that represents a weapon ID, you now use the variable in the function GivePlayerWeapon, which uses 'weaponid' as a parameter:

        GivePlayerWeapon(playerid, id, 10000); // 'playerid' = player who typed command, 'id' = weapon id they entered after the command
        //[referred to as a 'parameter', similar concept to how functions have parameters, but this is for in-game commands.]
        return 1;
    }
}

There, that command should work, it will give the player who entered it whatever weapon ID they type with 10000 ammo.

For instance, if player 3 entered '/getweapon 34' it will give player 4 a sniper rifle [id 34] with 10000 bullets

And in the script the function GivePlayerWeapon will be executed [scripting term that basically means when the function is used or 'called'] and the parameters for the function will be set to GetPlayerWeapon(3, 34, 10000); because 'playerid' = 3 [player who entered it] 'id' = 34 [number after the command or 'parameter'] 10000 [which is just in the function anyway]


I hope that helps you understand if there's anything else that you don't understand I can try and explain it in as much detail as possible so you understand
im using it because i don't know how to use something else like the thing that you used and i got no one to teach me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)