SA-MP Forums Archive
How I do command that add player to activity? - 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 I do command that add player to activity? (/showthread.php?tid=517989)



How I do command that add player to activity? - LOLtz120 - 07.06.2014

How I do command that add player to activity?
/addplayer [id]
the Variable is InActivty[playerid] = 1;
How do I do that command? From what I understand I need to stock but it's really complicated ...

tnx for help!


Respuesta: How I do command that add player to activity? - SickAttack - 07.06.2014

Just put InActivty[id] = 1;.


Re: How I do command that add player to activity? - Konstantinos - 07.06.2014

Do you mean to set that variable to 1 for that ID given in the command?

pawn Код:
CMD:addplayer(playerid, params[])
{
    new id;
    if (sscanf(params, "r", id)) return SendClientMessage(playerid, -1, "Usage: /addplayer <ID/Part Of Name>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid player");
    if (InActivty[id] == 1) return SendClientMessage(playerid, -1, "That player is already in the activity");
    InActivty[id] = 1;
    SendClientMessage(playerid, -1, "You set that player in the activity");
    return 1;
}
Modify the texts because I don't get it exactly what you mean by "add player to activity".


Re: How I do command that add player to activity? - LOLtz120 - 07.06.2014

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Do you mean to set that variable to 1 for that ID given in the command?

pawn Код:
CMD:addplayer(playerid, params[])
{
    new id;
    if (sscanf(params, "r", id)) return SendClientMessage(playerid, -1, "Usage: /addplayer <ID/Part Of Name>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid player");
    if (InActivty[id] == 1) return SendClientMessage(playerid, -1, "That player is already in the activity");
    InActivty[id] = 1;
    SendClientMessage(playerid, -1, "You set that player in the activity");
    return 1;
}
Modify the texts because I don't get it exactly what you mean by "add player to activity".
tnx man!!!
but, if I do it like this:
Код:
if (strcmp("/addplayer", cmdtext, true, 10) == 0)
it's not work, why?


Re: How I do command that add player to activity? - Konstantinos - 07.06.2014

If you use strcmp, sscanf will still work I guess. Just change "params" to "cmdtext" and add the command in OnPlayerCommandText callback.


Re: How I do command that add player to activity? - LOLtz120 - 07.06.2014

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
If you use strcmp, sscanf will still work I guess. Just change "params" to "cmdtext" and add the command in OnPlayerCommandText callback.
Could be an example?


Re: How I do command that add player to activity? - Faisal_khan - 07.06.2014

@LOLtz120 care to tread the reply once again.
pawn Код:
{
    new id;
    if (sscanf(params/*change this params to cmdtext*/, "r", id)) return SendClientMessage(playerid, -1, "Usage: /addplayer <ID/Part Of Name>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid player");
    if (InActivty[id] == 1) return SendClientMessage(playerid, -1, "That player is already in the activity");
    InActivty[id] = 1;
    SendClientMessage(playerid, -1, "You set that player in the activity");
    return 1;
}
And add this code under:
pawn Код:
if (strcmp("/addplayer", cmdtext, true, 10) == 0)



Re: How I do command that add player to activity? - LOLtz120 - 07.06.2014

tnx guys!