Scramble
#1

How can i create a simple scramble with my own words?

Like /scramble word to solve it


and like random math questions to get money
Reply
#2

A scramble ?
Reply
#3

A message sends like

Find the mysterious word: rellik

/scramble killer

and the player gets a random amount of money / score
Reply
#4

Hmmm, you would need to create a string like
pawn Код:
new scramble[70];
And use strcmp to compare the word generated with that string https://sampwiki.blast.hk/wiki/Strcmp

And then the /scramble would be 'sscanf(params,"s[128]",params)' and if the strcmp returns 0, give him the cash/score.
Reply
#5

Quote:
Originally Posted by Ananisiki
Посмотреть сообщение
How can i create a simple scramble with my own words?

Like /scramble word
just coded a small FS for that scramble thingy,
hope it helps you to understand how something like this could be done.

pawn Код:
/*
    Created this in some mins, it's simple and meant to stay simple,
    don't go searching for stuff which actually could've be done better.
    Some parts could've been, but i did not care at the time of creation,
    as this here is nothing seriouis, you could call it a "snippet" - CutX
*/

#include <a_samp>
#include <sscanf2>
#include <YSI\y_commands>

#define gray 0x8C8C8CFF
#define orange 0xFF641AFF
#define red 0xFF0000FF

new scram[30],word[30];//change size for longer scrambles

public OnFilterScriptInit()
{
    word[0] = EOS;//jep it's needed here cuz there could
                  //be something else inside already at that address.
                  //needed for that check in OnPlayerText
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(word[0] != EOS)
    {
        if(!strcmp(text,word))//case sensitive
        {
            new msg[78],pn[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pn,sizeof pn);
            format(msg,sizeof msg,"%s has solved the scramble! {FFFFFF}%s",pn,text);
            SendClientMessageToAll(orange,msg);
            word[0] = EOS;
            GivePlayerMoney(playerid, 5000);//just use random(); if you want random cash
            GameTextForPlayer(playerid,"~g~$ +5000",3000,3);
            SendClientMessage(playerid,orange,"Congratulations on solving the scramble!");
            return 0;
        }
    }
    return 1;
}

YCMD:scramble(playerid, params[], help)
{
    if(help) SendClientMessage(playerid, gray, "/scramble is used to generate a scramble");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"You can't use this!");//replace this with your admin stuff
    new s[30];//change size for longer scrambles
    if(sscanf(params,"s[31]",s)) return SendClientMessage(playerid,red,"USAGE: /scramble [word]");
    strcpy(word,s);
    new msg[63];
    format(msg, sizeof msg, "Scramble created! your word: %s",s);
    SendClientMessage(playerid,-1,msg);
    CreateScramble(s);
    format(msg, sizeof msg, "Solve the scramble! {FFFFFF}%s",scram);
    SendClientMessageToAll(orange,msg);
    return 1;
}

stock CreateScramble(s[])
{
    new tmp[2], num, len = strlen(s);
    for(new i=0; s[i] != EOS; i++)
    {
        num = random(len);
        tmp[0] = s[i];
        tmp[1] = s[num];
        s[num] = tmp[0];
        s[i] = tmp[1];
    }
    strcpy(scram,s);
    return 1;
}
Reply
#6

I want to add like random words in the script instead of creating a scramble from ingame, help pls
Reply
#7

Bump
Reply
#8

Here, it's amazing what the search button can do
http://*******/XzGRxC
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)