Converted from strcmp to 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: Converted from strcmp to zcmd (
/showthread.php?tid=391463)
Converted from strcmp to zcmd -
SafewayLol - 10.11.2012
strcmp
Код:
if(strcmp(cmd, "/poisondart", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
new para1 = ReturnUser(tmp);
if (PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
{
if (PlayerInfo[playerid][pRank] >= 5)
{
if(PlayerInfo[para1][pMember] == 8||PlayerInfo[para1][pLeader] == 8)
{
SendClientMessage(playerid,COLOR_LIGHTBLUE,"Don't poison dart your team-mates!");
return 1;
}
if(playerid == para1)
{
SendClientMessage(playerid,COLOR_LIGHTBLUE,"I don't think you want to poison yourself!");
return 1;
}
else if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /poisondart [playerid/PartOfName]");
return 1;
}
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
if (!(ProxDetectorS(10.0, playerid, giveplayerid)))
{
SendClientMessage(playerid, COLOR_WHITE, "Your target is too far.");
}
else
{
GetPlayerName(para1, sendername, sizeof(sendername));
format(string, sizeof(string), "You have shot a poison dart into %s's neck",sendername);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
SetTimer("Target",6000,0);
}
}
else
{
format(string, sizeof(string), "That person isn't online!");
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You are not allowed to use that command!");
}
}
return 1;
}
return 1;
}
zcmd
Код:
CMD:poisondart(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
new para1 = ReturnUser(tmp);
if (PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
{
if (PlayerInfo[playerid][pRank] >= 5)
{
if(PlayerInfo[para1][pMember] == 8||PlayerInfo[para1][pLeader] == 8)
{
SendClientMessage(playerid,COLOR_LIGHTBLUE,"Don't poison dart your team-mates!");
return 1;
}
if(playerid == para1)
{
SendClientMessage(playerid,COLOR_LIGHTBLUE,"I don't think you want to poison yourself!");
return 1;
}
else if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /poisondart [playerid/PartOfName]");
return 1;
}
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
if (!(ProxDetectorS(10.0, playerid, giveplayerid)))
{
SendClientMessage(playerid, COLOR_WHITE, "Your target is too far.");
}
else
{
GetPlayerName(para1, sendername, sizeof(sendername));
format(string, sizeof(string), "You have shot a poison dart into %s's neck",sendername);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
SetTimer("Target",6000,0);
}
}
else
{
format(string, sizeof(string), "That person isn't online!");
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You are not allowed to use that command!");
}
}
return 1;
}
return 1;
}
Would this seem right? Also if i want the command to only be used by the faction hitman agency what would i change it too? thanks
Re: Converted from strcmp to zcmd -
Yves - 07.02.2013
replace tmp = strtok(cmdtext, idx); to tmp = strtok(params, idx);