01.04.2013, 20:35
How would I make a command like:
/setscore [team] [score]
Like if I did
/setscore 1 3
Using params with strcmp?
/setscore [team] [score]
Like if I did
/setscore 1 3
Using params with strcmp?
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/setscore", true, 9)) // 9 is the length of /setscore
{
if(!cmdtext[9])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /setscore [team] [score]");
new receiverid;
new score;
SetPlayerScore(receiverid,score);
return 1;
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/setscore", true))
{
if(!IsPlayerAdmin) return 0;
new tmp[128];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,-1,"Usage: /setscore [ID] [SCORE]");
if(!IsPlayerConnected(tmp)) return SendClientMessage(playerid,-1,"Player not found.");
new id = strval(tmp);
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,-1,"Usage: /setscore [ID] [SCORE]");
SetPlayerScore(id,tmp);
return 1;
}
return 0;
}
new tmp[128];
tmp = strtok(cmdtext,teamid, score);
if(!strlen(tmp)) return SendClientMessage(playerid,-1,"Usage: /setscore [TEAM ID] [SCORE]");
if(!gTeam[tmp] == TEAM_HOME || gTeam[tmp] TEAM_AWAY) return SendClientMessage(playerid,-1,"Invalid team id.");
new id = strval(tmp);
tmp = strtok(cmdtext,teamid, score);
if(!strlen(tmp)) return SendClientMessage(playerid,-1,"Usage: /setscore [TEAM ID] [SCORE]");
teamhomescore = tmp;
return 1;
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/setscore", true))
{
if(!IsPlayerAdmin) return 0;
new tmp[128];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,-1,"Usage: /setscore [TeamID] [Score]");
if(tmp < 1 || tmp > 2) return SendClientMessage(playerid,-1,"Invalid team ID.");
new id = strval(tmp);
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,-1,"Usage: /setscore [ID] [SCORE]");
new score = strval(tmp);
switch(id)
{
case 1: SetPlayerScore(teamhomescore,score);
case 2: SetPlayerScore(teamawayscore,score);
}
return 1;
}
return 0;
}