SA-MP Forums Archive
How to convert this into a strcmp - 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: How to convert this into a strcmp (/showthread.php?tid=410525)



How to convert this into a strcmp - RiChArD_A - 25.01.2013

How can I make this into a strcmp command AND DON'T ASK why I want it to be like that. Thank you.
Код:
dcmd_setscore(playerid,params[]){
    if (PlayerInfo[playerid][level] <3 && IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid,COLOR_RED,"You need to be a full administrator to use this command!");
    new id,val,string[128];
    if (sscanf(params,"ii",id,val)) return SendClientMessage(playerid,COLOR_GREEN,"Usage: /setscore [playerid] [value]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player is not connected");
    if(playerid == id) return SendClientMessage(playerid,COLOR_RED,"Don't abuse");
    SetPlayerScore(id,val);
    new pName[MAX_PLAYER_NAME];
    new vName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,32);
    GetPlayerName(id,vName,32);
    format(string,sizeof string,"{FF0A00}-[Administrator: %s]- {FFFFFF}changed %s's score to %i.",pName,vName,val);
    SendClientMessageToAll(COLOR_GRAY,string);
    return 1;
}



Re: How to convert this into a strcmp - MP2 - 25.01.2013

Why do you want it to be like that?



Look in one of the many filterscripts that comes in the server package - or look at another command in your mode. It's not difficult to figure out.

You should really use dcmd/zcmd though. Who the hell uses strcmp anymore?!


Respuesta: Re: How to convert this into a strcmp - RiChArD_A - 25.01.2013

Quote:
Originally Posted by MP2
Посмотреть сообщение
Why do you want it to be like that?



Look in one of the many filterscripts that comes in the server package - or look at another command in your mode. It's not difficult to figure out.

You should really use dcmd/zcmd though. Who the hell uses strcmp anymore?!
IIIIIIIII DON"T CAREEEEEEEEEEEE!!!!!!!!! WHY EVERYBODY ASK THE SAME CHI* STOPPPPPP!!!!
AND I DON'T KNOW HOW TO USE ALL THOSE PROCESSORS!!!!!!



AW: How to convert this into a strcmp - Blackazur - 25.01.2013

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    	if (strcmp("/setscore", cmdtext, true) == 0)
   {
    if (PlayerInfo[playerid][level] <3 && IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid,COLOR_RED,"You need to be a full administrator to use this command!");
    new id,val,string[128];
    if (sscanf(params,"ii",id,val)) return SendClientMessage(playerid,COLOR_GREEN,"Usage: /setscore [playerid] [value]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player is not connected");
    if(playerid == id) return SendClientMessage(playerid,COLOR_RED,"Don't abuse");
    SetPlayerScore(id,val);
    new pName[MAX_PLAYER_NAME];
    new vName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,32);
    GetPlayerName(id,vName,32);
    format(string,sizeof string,"{FF0A00}-[Administrator: %s]- {FFFFFF}changed %s's score to %i.",pName,vName,val);
    SendClientMessageToAll(COLOR_GRAY,string);
    return 1;
}
But i dont think that Commands with Parameters work with strcmp.


Re: Respuesta: Re: How to convert this into a strcmp - Neil. - 25.01.2013

Quote:
Originally Posted by Lauder
Посмотреть сообщение
IIIIIIIII DON"T CAREEEEEEEEEEEE!!!!!!!!! WHY EVERYBODY ASK THE SAME CHI* STOPPPPPP!!!!
AND I DON'T KNOW HOW TO USE ALL THOSE PROCESSORS!!!!!!
You should really look into using ZCMD and SSCANF. They're a pretty good combination. They work much faster and better. Also you should look into the source code of some game modes. I learn about those processors by doing that.


Respuesta: AW: How to convert this into a strcmp - RiChArD_A - 25.01.2013

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    	if (strcmp("/setscore", cmdtext, true) == 0)
   {
    if (PlayerInfo[playerid][level] <3 && IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid,COLOR_RED,"You need to be a full administrator to use this command!");
    new id,val,string[128];
    if (sscanf(params,"ii",id,val)) return SendClientMessage(playerid,COLOR_GREEN,"Usage: /setscore [playerid] [value]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player is not connected");
    if(playerid == id) return SendClientMessage(playerid,COLOR_RED,"Don't abuse");
    SetPlayerScore(id,val);
    new pName[MAX_PLAYER_NAME];
    new vName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,32);
    GetPlayerName(id,vName,32);
    format(string,sizeof string,"{FF0A00}-[Administrator: %s]- {FFFFFF}changed %s's score to %i.",pName,vName,val);
    SendClientMessageToAll(COLOR_GRAY,string);
    return 1;
}
But i dont think that Commands with Parameters work with strcmp.
Look:
Код:
DM.pwn(1007) : error 029: invalid expression, assumed zero
C:\WINDOWS\security\kidn\Server\Global DM [0.3x]\gamemodes\DM.pwn(1007) : warning 215: expression has no effect
C:\WINDOWS\security\kidn\Server\Global DM [0.3x]\gamemodes\DM.pwn(1007) : error 001: expected token: ";", but found "]"
C:\WINDOWS\security\kidn\Server\Global DM [0.3x]\gamemodes\DM.pwn(1007) : error 029: invalid expression, assumed zero
C:\WINDOWS\security\kidn\Server\Global DM [0.3x]\gamemodes\DM.pwn(1007) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re: How to convert this into a strcmp - Neil. - 25.01.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        if (strcmp("/setscore", cmdtext, true) == 0)
   {
    if (PlayerInfo[playerid][level] < 3 && IsPlayerAdmin(playerid))
    {
    new id,val,string[128];
    if (sscanf(params,"ii",id,val)) return SendClientMessage(playerid,COLOR_GREEN,"Usage: /setscore [playerid] [value]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player is not connected");
    if(playerid == id) return SendClientMessage(playerid,COLOR_RED,"Don't abuse");
    SetPlayerScore(id,val);
    new pName[MAX_PLAYER_NAME];
    new vName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,32);
    GetPlayerName(id,vName,32);
    format(string,sizeof string,"{FF0A00}-[Administrator: %s]- {FFFFFF}changed %s's score to %i.",pName,vName,val);
    SendClientMessageToAll(COLOR_GRAY,string);
    }
   }
    return 1;
}



Re: How to convert this into a strcmp - Rayan_black - 25.01.2013

With such an attitude? no one will do the work for you. You should be thankful because people are helping you for free.


Respuesta: How to convert this into a strcmp - RiChArD_A - 25.01.2013

ALRIGHT YOU WONNN!!!!!
WHAT I HAVE DO TO USE IT A IT IS NOW. WITH DCMD ZCMD AN ALL TAHT



Re: Respuesta: How to convert this into a strcmp - Neil. - 25.01.2013

Quote:
Originally Posted by Lauder
Посмотреть сообщение
ALRIGHT YOU WONNN!!!!!
WHAT I HAVE DO TO USE IT A IT IS NOW. WITH DCMD ZCMD AN ALL TAHT
Your font size is killing me
pawn Код:
CMD:setplayerscore(playerid, params[])
{
    if (PlayerInfo[playerid][level] < 3 && IsPlayerAdmin(playerid))
    {
    new id,val,string[128];
    if (sscanf(params,"ii",id,val)) return SendClientMessage(playerid,COLOR_GREEN,"Usage: /setscore [playerid] [value]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player is not connected");
    if(playerid == id) return SendClientMessage(playerid,COLOR_RED,"Don't abuse");
    SetPlayerScore(id,val);
    new pName[MAX_PLAYER_NAME];
    new vName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,32);
    GetPlayerName(id,vName,32);
    format(string,sizeof string,"{FF0A00}-[Administrator: %s]- {FFFFFF}changed %s's score to %i.",pName,vName,val);
    SendClientMessageToAll(COLOR_GRAY,string);
    }
return 1;
 }
Remember, download and compile it with all the latest ZCMD and SSCANF includes and plugin. Else it will not work.