Need some help with command /random
#1

hello i got a quistion how can i say something random like this:

i type /random
then it says on the server [Hippie]:/hit 1 1000
i do it again /random
then it says on the server [Hippe]:/hit 6 1000
i do it again /random
then it says on the server [Hippe]:/hit 3 1000

i got this already but i the player must say it not the server....
need some help for it thank you already


if (strcmp("/random", cmdtext, true, 10) == 0)
{
if(IsPlayerAdmin(playerid)==1)
{
new hit = random(14);
if(hit == 1)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 1 1000");
}
else if(hit == 2)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 2 1000");
}
else if(hit == 3)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 3 1000");
}
else if(hit == 4)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 4 1000");
}
else if(hit == 5)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 5 1000");
}
else if(hit == 6)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 6 1000");
}
else if(hit == 7)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 7 1000");
}
else if(hit ==
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 8 1000");
}
else if(hit == 9)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 9 1000");
}
else if(hit == 10)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 10 1000");
}
else if(hit == 11)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 11 1000");
}
else if(hit == 12)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 12 1000");
}
else if(hit == 13)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 13 1000");
}
else if(hit == 14)
{
SendClientMessage(playerid, 0xFFFFFFAA, "/hit 14 1000");
}
return 1;
}
}
Reply
#2

pawn Код:
random(14);//will create a number between 0-13.
https://sampwiki.blast.hk/wiki/Random
http://forum.sa-mp.com/index.php?top...0635#msg570635
https://sampwiki.blast.hk/wiki/Format

thanks ssǝן‾ʎ should have posted that as well.

I think thats what you mean adapt it for your needs.

Reply
#3

sendmessagetoall is not good, but how can i say it not true the server but true the player [playername]: hallo not server:hello
Reply
#4

pawn Код:
if (strcmp("/random", cmdtext, true, 10) == 0)
{
  if(IsPlayerAdmin(playerid))
  {
    new str[128];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    new hit = random(14);
    format(str,sizeof(str),"%s:/hit %d 1000",playername,hit);
    SendClientMessageToAll(0xFFFFFFAA,str);
  }
  return 1;
}
This should work
Reply
#5

i think he needs SendPlayerMessageToAll
Reply
#6

Quote:
Originally Posted by !MaVe
i think he needs SendPlayerMessageToAll
He did it.
pawn Код:
if (strcmp("/random", cmdtext, true, 10) == 0)
{
   if(IsPlayerAdmin(playerid)==1)
   {
     new str[128];
     new playername[MAX_PLAYER_NAME];
     GetPlayerName(playerid,playername,sizeof(playername));
     new hit = random(14);
     format(str,sizeof(str),"%s:/hit %d 1000",playername,hit);
     SendClientMessageToAll(0xFFFFFFAA,str);
   }
   return 1;
}
Reply
#7

not SendClientMessageToAll, SendPlayerMessageToAll
Reply
#8

Quote:
Originally Posted by !MaVe
not SendClientMessageToAll, SendPlayerMessageToAll
SendPlayerMessageToAll will look like this,won't it?:
PM from 'playername here'(his id):/hit 'value' 1000
Reply
#9

Quote:
Originally Posted by CracKman
Quote:
Originally Posted by !MaVe
not SendClientMessageToAll, SendPlayerMessageToAll
SendPlayerMessageToAll will look like this,won't it?:
PM from 'playername here'(his id):/hit 'value' 1000
No, it will send a default chat message.
Reply
#10

pawn Код:
if (strcmp("/random", cmdtext, true, 10) == 0)
{
   if(IsPlayerAdmin(playerid)==1)
   {
     new str[128];
     new hit = random(14);
     format(str,sizeof(str),"/hit %d 1000",hit);
     SendPlayerMessageToAll(playerid,str);
     return 1;
   }
   return 0;
}
Hm, really it sends a default chat message...I will take it into a count.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)