simple command ZCMD
#1

I want to have a simple command using ZCMD.

Command name:
/changemission

ZCMD:
CMD:changemission(playerid, params[])
{
here the code so hope you got it for me
}

So what it have to do is that if I say /changemission that it will send a RconCommand changemode like this:
SendRconCommand("changemode <input>"); so it will replace the <input> with your input. ( whatever you type in the chat.

So if I say for example: /changemission Deathmatch , that the command will be: SendRconCommand("changemode Deathmatch");

Hope you can help me!
Reply
#2

CMD:changemission(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You need to be RCON admin to use it");
SendRconCommand("changemode Deathmatch");
return 1;
}

+Rep if i helped you
Reply
#3

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
CMD:changemission(playerid, params[])
{
if(!IsPlayerAdmin) return SendClientMessage(playerid,-1,"You need to be RCON admin to use it");
SendRconCommand("changemode Deathmatch");
return 1;
}
No Ali, the "mode" has to be replaced with my input.
Reply
#4

PHP код:
CMD:changemission(playerid,params[]){
    if(!
IsPlayerAdmin(playerid)) return 0;
    new 
name[64], buffer[100];
    if(
sscanf(params,"s[64]",name)) return SendClientMessage(playerid,COLOR_ERROR1,"››› Use: /changemission <name>");
    
format(buffer,sizeof buffer,"changemode %s",name);
    
SendRconCommand(buffer);
    return 
1;

//edit params[]
Reply
#5

REMOVED
Reply
#6

PHP код:
#include <sscanf2>
CMD:changemission(playeridparams[])
{
    if(
IsPlayerAdmin(playerid)
    {
        new 
mission[50], cmd[50]; //strings
        
if(sscanf(params"s"mission)) return SendClientMessage(playerid, -1"USAGE: /changemission (mission)"); //if playerid doesnt type in mission name playerid will get error message
        
format(cmdsizeof(cmd), "changemode %s"mission); //formatting the string to be used in SendRconCommand
        
SendRconCommand(cmd); //calling the command and changing the gamemode     
    
}
    return 
1;

Links:
sscanf2 (needed to use code): https://sampforum.blast.hk/showthread.php?tid=570927
SendRconCommand: https://sampwiki.blast.hk/wiki/SendRconCommand
Reply
#7

pawn Код:
CMD:changemission(playerid, params[])
{
     new string[64], name[24];
     if(!IsPlayerAdmin(playerid))
          return SendClientMessage(playerid, -1, "[ERROR] You need to be RCON to use it.");
     if(sscanf(params,"s[64]",name))
          return SendClientMessage(playerid, -1, "USAGE: /changemission [gamemode]");
     format(string, sizeof(string),"changemode %s", name);
     SendRconCommand(string);
     return 1;
}
Reply
#8

Thanks !
Reply
#9

Why would you use sscanf?

Params = whatever you type after the command.
It's already a string, you don't have to use sscanf for that.
Reply


Forum Jump:


Users browsing this thread: