SA-MP Forums Archive
simple command ZCMD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: simple command ZCMD (/showthread.php?tid=591326)



simple command ZCMD - Fantje - 10.10.2015

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!


Re: simple command ZCMD - Logic_ - 10.10.2015

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


Re: simple command ZCMD - Fantje - 10.10.2015

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.


Re: simple command ZCMD - AbyssMorgan - 10.10.2015

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[]


Re: simple command ZCMD - Logic_ - 10.10.2015

REMOVED


Re: simple command ZCMD - SnG.Scot_MisCuDI - 10.10.2015

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


Re: simple command ZCMD - Galhardo - 10.10.2015

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;
}



Re: simple command ZCMD - Fantje - 10.10.2015

Thanks !


Re: simple command ZCMD - Stinged - 10.10.2015

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.