SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 05/03/2009, 05:16 PM   #171
ғαιιοцт
High-roller
 
ғαιιοцт's Avatar
 
Join Date: Feb 2008
Posts: 1,428
Reputation: 188
Default Re: Useful Snippets

Quote:
Originally Posted by NigNog1
I find that hard to beleive that you successfully tested it. It still won't work.

hmm it should work
I don't see anything wrong
ғαιιοцт is offline   Reply With Quote
Old 05/03/2009, 05:51 PM   #172
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Useful Snippets

My code is shorter and it does the same effect, also it doesn't have bugs.
pawn Code:
RPName(playerid)
{
  new n[24];
  GetPlayerName(playerid,n,24);
  for(new i=0;i<strlen(n);i++)
  if(n[i]=='_') n[i]=' ';
  return n;
}
I don't see any point in using yours instead of mine.
MenaceX^ is offline   Reply With Quote
Old 05/03/2009, 05:55 PM   #173
Nubotron
Big Clucker
 
Join Date: Jan 2008
Posts: 156
Reputation: 0
Default Re: Useful Snippets

You maybe want to know that shorter isn't always better...and your code is like, 3 times slower (just a guess) that *****'s one. If you care more about code beauty than efficiency, stop scripting already! You can have efficient and beautyfull code but you should never sacrifice speed or memory usage.

Just a question: have you read ***** post fully or just first line?

And just so you know, *****'s code is even shorter than yours, once you remove it's brackets.
Nubotron is offline   Reply With Quote
Old 05/03/2009, 06:05 PM   #174
ғαιιοцт
High-roller
 
ғαιιοцт's Avatar
 
Join Date: Feb 2008
Posts: 1,428
Reputation: 188
Default Re: Useful Snippets

Quote:
Code:
RPName(playerid)
{
	new
		n[MAX_PLAYER_NAME],
		i = -1;
	GetPlayerName(playerid, n, MAX_PLAYER_NAME);
	for (new i = 0, j = strlen(n); i < j; i++)
	{
		if (n[i] == '_')
		{
			n[i] = ' ';
		}
	}
	return n;
}

// native function
strlen(const str[])
{
	new
		i = 0;
	while (str[i])
	{
		i++;
	}
	return i;
}
why create "i" twice?
ғαιιοцт is offline   Reply With Quote
Old 11/03/2009, 01:21 AM   #175
Zoopaman
Big Clucker
 
Join Date: Oct 2008
Posts: 158
Reputation: 0
Default *******

Yay I finally have done it! Inspired by this, I made a *******-style PM system (but you can actually make a real SA:MP ******* with this )

Syntax: "@name/id message" or "@ name/id message" - both work (I haven't tested it with names w/ spaces tho).

Ok I hope I don't miss a part of the code :P And pls don't dis this code because even I'm quite surprised it works, since it came to me while daydreaming :P

So here we go.
Above all:
pawn Code:
forward OnPlayerAtCmd(playerid, cmdtext[]);

in OnPlayerText:
pawn Code:
if(text[0] == '@') {OnPlayerAtCmd(playerid, text[1]); return 0;}

out of callbacks:
pawn Code:
public OnPlayerAtCmd(playerid, cmdtext[])
{
    new idx;
    new string[128];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[128];
    new tmp[128];
    new giveplayerid;
    cmd[idx] = cmdtext[0]; // this is important - it's what lets you *not* have the whole command and enter the name right after '@'
//The rest except the one above line is pretty much usual PM stuff. This sample is from GodFather (sorry, haters :))
//Also, I'm not sure, but I think that [idx] and [0] can be different. I tried replacing [0] with [1] and [2], but no change whatsoever.
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COL_HELP, "USAGE: @[Player ID/Name] [Message]");
        return 1;
    }
    giveplayerid = ReturnUser(tmp);
    if (IsPlayerConnected(giveplayerid))
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COL_HELP, "USAGE: @[Player ID/Name] [Message]");
            return 1;
        }
        format(string, sizeof(string), "New reply from %s (ID: %d): '%s'", sendername, playerid, (result));
        SendClientMessage(giveplayerid, COL_REPLY, string);
        return 1;
    } else {
        SendClientMessage(giveplayerid, COL_ERROR, "Recipient not online");
    }
    return 1;
}

Feel free to use it and add parameters and IsPlayerConnected's and whatever
Zoopaman is offline   Reply With Quote
Old 11/03/2009, 01:41 AM   #176
ICECOLDKILLAK8
High-roller
 
Join Date: Aug 2008
Posts: 1,154
Reputation: 5
Default Re: Useful Snippets

Names with spaces get cut in SA:MP AFAIK e.g. "Hai Dere" would become "Hai" i think
__________________
IVMP
ICECOLDKILLAK8 is offline   Reply With Quote
Old 11/03/2009, 03:04 PM   #177
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Useful Snippets

SendDeathMessage was made by ******?
MenaceX^ is offline   Reply With Quote
Old 12/03/2009, 03:53 AM   #178
FrazZ
Big Clucker
 
Join Date: Feb 2009
Posts: 181
Reputation: 0
Default Re: Useful Snippets

yea, according to everyone :P
FrazZ is offline   Reply With Quote
Old 12/03/2009, 03:17 PM   #179
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Re: Useful Snippets

Don't wanna be harsh, but I hope you know that ****** was one of the devs?
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 12/03/2009, 03:24 PM   #180
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Useful Snippets

Quote:
Originally Posted by lrZ^
Don't wanna be harsh, but I hope you know that ****** was one of the devs?
Yes I know and I knew it -__-
I just didn't know he made the SendDeathMessage.
MenaceX^ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
READ Usefull Links to snippets and other -Sneaky- Help Archive 5 02/05/2009 11:22 AM


All times are GMT. The time now is 06:28 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.