How do I get/check a players position? + Is this script right?
#1

I tried to make a spam checker is this right?
PHP код:
#include <a_samp>
public SpamCheck()
{
//stores first message
OnPlayerText(playeridtext[]);
new 
pText[144];
format (pTextsizeof (pText), "%s"playeridtext)
//stores second message
OnPlayerText(playeridtext[]);
new 
pTextb[144];
format (pTextbsizeof (pTextb), "%s"playeridtext)
if (
pTextb==pText)
{
SendClientMessage(playeridFF0000"Please Stop Spamming!");
return 
1;
}
else
{
return;
}

Also what is the function to get a players xyz and check their xyz I cant seem to find it in the samp.inc
Reply
#2

do you even understand what are you doing?
you just can't write something what is on your mind and hope for it to work.
PHP код:
#define scm SendClientMessage
new OldMsg[MAX_PLAYERS][128];
public 
OnPlayerText(playerid,text[]){
    if(!
strlen(text) || !strcmp(OldMsg[playerid],text,true)){
        
scm(playerid,-1,"Don't repeat your message!");
        return 
0;
    }
    
strmid(OldMsg[playerid],text,0,128,128);
    return 
1;

Reply
#3

Not tested, but should work fine:

pawn Код:
CMD:check(playerid, params[])
{
    new targetid;

    new Float:pX,
        Float:pY,
        Float:pZ;

    new string[128];

    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/check (ID)");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player isn't connected.");
   
    GetPlayerPos(targetid, pX, pY, pZ);
    format(string, sizeof(string), "ID %d position: %f, %f, %f", targetid, pX, pY, pZ);
    SendClientMessage(playerid, -1, string);

    return 1;
}
Reply
#4

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
do you even understand what are you doing?
you just can't write something what is on your mind and hope for it to work.
PHP код:
#define scm SendClientMessage
new OldMsg[MAX_PLAYERS][128];
public 
OnPlayerText(playerid,text[]){
    if(!
strlen(text) || !strcmp(OldMsg[playerid],text,true)){
        
scm(playerid,-1,"Don't repeat your message!");
        return 
0;
    }
    
strmid(OldMsg[playerid],text,0,128,128);
    return 
1;

No I don't understand what I'm doing!
This is my first pawn script I've written so I am practicing to learn as I go along.

Why do I have to #define sendclientmessage?
Can you tell me what is wrong with my script instead of spoon feeding me the fix? Thank you
Reply
#5

To start:
1. OnPlayerText is a callback (public OnPlayerText(playerid, text[]));
2. You can't use callbacks inside custom functions.
3. Your code doesn't make sense at all. Have you tried compiling your script with that code in there? If you did, you'd get a bunch of errors.
Reply
#6

Quote:
Originally Posted by Twizted
Посмотреть сообщение
To start:
1. OnPlayerText is a callback (public OnPlayerText(playerid, text[]));
2. You can't use callbacks inside custom functions.
3. Your code doesn't make sense at all. Have you tried compiling your script with that code in there? If you did, you'd get a bunch of errors.
No, my computer is broken so I can not test the code. I'm doing everything on my phone so yeah.
Oh! I didnt realize OnPlayerText was a callback lol. Thank you!

Also im having trouble understanding public functions. Does making a function public make it able to be called from anywhere in the script?
Reply
#7

Quote:
Originally Posted by doodlebob666
Посмотреть сообщение
No, my computer is broken so I can not test the code. I'm doing everything on my phone so yeah.
Oh! I didnt realize OnPlayerText was a callback lol. Thank you!

Also im having trouble understanding public functions. Does making a function public make it able to be called from anywhere in the script?
So, let me get this straight. You're writing and reading codes from your phone?

Is this a joke? How do you intend to test this? Post another thread and ask if it works?

Just Stop.
Reply
#8

Quote:
Originally Posted by Twizted
Посмотреть сообщение
2. You can't use callbacks inside custom functions.
Actually, you can. But not like that.
Reply
#9

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
So, let me get this straight. You're writing and reading codes from your phone?

Is this a joke? How do you intend to test this? Post another thread and ask if it works?

Just Stop.
I don't intend to test the code. I don't know why you would even continue assuming that after I stated I'm using a phone. All I am doing is learning pawn and practicing writting code. I posted it here so you guys could be my compilers and show me the errors.
Reply
#10

Quote:
Originally Posted by raydx
Посмотреть сообщение
Actually, you can. But not like that.
Whats the correct way to callback in a custom function? And I thought a callback was a command to execute the function again. So why can't I put a callback in a custom function?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)