Need Help fast,
#1

So look, im trying to make a coinflip thingy, and idk whats happening to this, i've i already read:https://sampwiki.blast.hk/wiki/random, i tried following whats there, but im getting errorz.

My new stuff

Код:
new value = random(2);

new string1[128];

new Float:RandomSpawn[][2] =
{
    {"%s flipped a coin! landed on heads"};
    {"%s flipped a coin! landed on tails"};
};
THE STUFF I MADE:

Код:
	if (strcmp("/coin", cmdtext, true, 10) == 0)
	{
	new name[128];
	new string[128];
    GetPlayerName(playerid,name,128);
  	format(string, sizeof(name), RandomSpawn[0], RandomSpawn[1], GetPlayerName);
	SendClientMessageToAll(0xA586B8FF, name);
		return 1;
	}
MY ERRORS:

Код:
C:\Users\PC1\Desktop\CZCNRSF\CZCNRSF\CNRSF\filterscripts\flipcoin.pwn(122) : error 017: undefined symbol "RandomSpawn"
C:\Users\PC1\Desktop\CZCNRSF\CZCNRSF\CNRSF\filterscripts\flipcoin.pwn(122) : warning 215: expression has no effect
C:\Users\PC1\Desktop\CZCNRSF\CZCNRSF\CNRSF\filterscripts\flipcoin.pwn(122) : error 001: expected token: ";", but found "]"
C:\Users\PC1\Desktop\CZCNRSF\CZCNRSF\CNRSF\filterscripts\flipcoin.pwn(122) : error 029: invalid expression, assumed zero
C:\Users\PC1\Desktop\CZCNRSF\CZCNRSF\CNRSF\filterscripts\flipcoin.pwn(122) : fatal error 107: too many error messages on one line
Can Anyone help me?
Reply
#2

Its not going like that m8..

Read this https://sampforum.blast.hk/showthread.php?tid=581106

BUT READ DON'T COPY-PASTE
Reply
#3

oh thanks, i already read that, i tried it, but it doesnt work, but i found out that im missing one stock, i got it right now, but my new problem is this, i dunno how to fix it.

error 033: array must be indexed (variable "name")
Reply
#4

give me that line of code
Reply
#5

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Its not going like that m8..

Read this https://sampforum.blast.hk/showthread.php?tid=581106

BUT READ DON'T COPY-PASTE
Don't mean to offend man but that does seem like alot of work for a simple task such as a coin flip.

OT: Try this sean,

PHP код:
stock GetCoilFlip(playerid)
{
    new 
string[64], playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    new 
coinflip;
    
coinflip random(2);//only two cases occur here and thats 0 and 1
    
if(coinflip == 0)
    {
        
format(string,sizeof(string),"%s flipped a coin! landed on heads",playername);
    }
    else
    {
        
format(string,sizeof(string),"%s flipped a coin! landed on tails",playername);
    }
    return 
string
Use it like this
PHP код:
SendClientMessage(playerid0xAFAFAFAAGetCoilFlip(playerid));
or
SendClientMessageToAll(0xAFAFAFAAGetCoilFlip(playerid)); 
You can use ProxDetector.. it's upto you
Reply
#6

You don't need all that, just use a ternary operator (like if/else statements) in format:
pawn Код:
if (strcmp("/coin", cmdtext, true) == 0)
{
    new p_name[MAX_PLAYER_NAME], string[57];
 
    GetPlayerName(playerid, p_name, sizeof p_name);

    format(string, sizeof string, "%s flipped a coin! landed on %s", p_name, !random(2) ? ("heads") : ("tails"));
    SendClientMessageToAll(0xA586B8FF, string);
    return 1;
}
Basically if what random returns is 0, it will pass "heads" as argument otherwise "tails".
Reply
#7

ugh, @Killa[DGZ] and @Micko123, i got this error

error 033: array must be indexed (variable "name")

and the line is over here,

stock GetName(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
name = strreplace(name, '_', ' '); //this line has the error
return name;
}
Reply
#8

Here you go
PHP код:
GetName(playerid)
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    return 
name;

Reply
#9

thanks for all the help guys! im done with it! thanks!
Reply
#10

ugh, when i do /coin in-game, it doesnt work, weird
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)