Little coding questions - For general minor queries 5

The easiest example of its usage I can give you is calling functions depending on input from user or any other interface that communicates with your script.

For example ZCMD. Without this function, the script would have to run string comparisons. With it, it doesn't have to.
Reply

Quote:
Originally Posted by SomeRandomGuy123
View Post
Alright, two questions:
1. How do I make it so PlayeAudioStreamForPlayer is sent within a 5 meter radius when a player types the command?
2. How do I StopAudioStreamForPlayer when it's played for 10 seconds?
Thanks
Quote:
Originally Posted by AndreT
View Post
The easiest example of its usage I can give you is calling functions depending on input from user or any other interface that communicates with your script.

For example ZCMD. Without this function, the script would have to run string comparisons. With it, it doesn't have to.
Quote:
Originally Posted by [HLF]Southclaw
View Post
Also, in external include files, if I had an include that added a gameplay feature that had an "OnSomething" event callback, I'd want to call that so people can use that callback in their own scripts (Like my "OnButtonPress" script)

If I used a normal function call like:

pawn Code:
// KeyStateChange > In button zone + pressed F
OnButtonPress(playerid, i);
That would mean the user has to have the function OnButtonPress in his script or he'll get an "Undefined Symbol" error. Obviously, that script only has ONE callback but some other frameworks I've been working on have a hell of a lot of callbacks for events, you may just want to use some but not all callbacks in these scripts so that's why we use this:

pawn Code:
// In the top
forward OnButtonPress(playerid, buttonid);

// KeyStateChange > In button zone + pressed F
CallLocalFunction("OnButtonPress", "dd", playerid, i);
This way it will call the function only if it exists, and as it's not a direct function call it won't give an error if the function doesn't exist because that's handled in run-time.
Okay, cheers.
Reply

Quote:
Originally Posted by Sydcul
Посмотреть сообщение
Hello,

If you have a integer and you want to add one, you would do
Код:
new integer;
integer = integer++;
Is there something similar to subtract one? Or do i have to do
Код:
integer = integer - integer;
Just curious.
integer--, logic
Reply

Quote:
Originally Posted by king_hual
Посмотреть сообщение
integer--, logic
Wasn't sure. Thanks.
Reply

anyone help me in it : https://sampforum.blast.hk/showthread.php?tid=405079
Thanks.
Reply

Hi,

This:
Код:
INI_String("password", iniplayerpassword[JustConnectedPlayerID], sizeof(iniplayerpassword[JustConnectedPlayerID]));
Throws this:
Код:
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : error 001: expected token: ")", but found "["
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : warning 215: expression has no effect
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : error 001: expected token: ";", but found "]"
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : error 029: invalid expression, assumed zero
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
On the very top of my script i got this:
Код:
new iniplayerpassword[MAX_PLAYERS];
The JustConnectedPlayerID thing is because i can't use playerid in a y_ini thing. I handle it in OnPlayerConnect, it's fine.
Reply

Quote:
Originally Posted by Sydcul
Посмотреть сообщение
Hi,

This:
Код:
INI_String("password", iniplayerpassword[JustConnectedPlayerID], sizeof(iniplayerpassword[JustConnectedPlayerID]));
Throws this:
Код:
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : error 001: expected token: ")", but found "["
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : warning 215: expression has no effect
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : error 001: expected token: ";", but found "]"
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : error 029: invalid expression, assumed zero
C:\Users\Sydcul\Desktop\Servers\samp03e_svr_R2_win32\pawno\sydculsroleplay.pwn(214) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
On the very top of my script i got this:
Код:
new iniplayerpassword[MAX_PLAYERS];
The JustConnectedPlayerID thing is because i can't use playerid in a y_ini thing. I handle it in OnPlayerConnect, it's fine.
You're trying to extract a string into an array (not a string-array). To fix, simply make it multidimensional and be sure to leave enough cells for the password to fit. If you're using whirlpool to hash the password, you'll need a 129 cell string.
Reply

I've got a little question, well I hope it is little anyway.

--
Reply

Hello,

I am making a login system. How can i prevent a player from going to class selection (so let the player stay on the view on the LS beach)? Or is this impossible and can i only block exiting the class selection (i know how to do that)?

I guess i've seen it on other servers.

EDIT: If i want to show 2 dialogs after each other, how can i wait for the first one to close to show the other one?
Reply

Is there any simpler way to convert an integer to a string than using valstr? In C#, for example, you can do integerVar.ToString();

I'm asking this because I have a simple 2-digit integer I want to use in a y_ini tag, but tags are strings, so to do so I have to:

1. Declare a string.
2. Use valstr to assign said integer to string.
3. Use the newly declared and assigned string variable.

I want it to work so that I can put it in like a string, while fetching the value of the integer. Something like this:
pawn Код:
"{myVar}"
But is this even possible?
Reply

Ok, so my thread got closed and i got told to get here.. so.. guys what is this object ID?



the object i want is the white object in the picture.
Reply

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
Ok, so my thread got closed and i got told to get here.. so.. guys what is this object ID?



the object i want is the white object in the picture.
Sorry, i don't know it, but maybe you should upload a higher resolution picture.
Reply

I'm using Incognitos checkpoint streamer and I've got it to successfully loop through all my array data and place checkpoints at specific co-ordinates but I have no idea how the script would know which checkpoint the player has actually entered...

Is there a callback for this? Every one I find requires a "checkpointid" but I haven't assigned a specific checkpointid, nor do I know how to do so.

This is what I'm using to place a checkpoint
pawn Код:
CreateDynamicCP(checkpointData[i][checkpointLoc][0], checkpointData[i][checkpointLoc][1], checkpointData[i][checkpointLoc][2], 2, -1, -1, -1, 100.0);
should I be using something like...

pawn Код:
new checkpoint1;
checkpoint1 = CreateDynamicCP(checkpointData[i][checkpointLoc][0], checkpointData[i][checkpointLoc][1], checkpointData[i][checkpointLoc][2], 2, -1, -1, -1, 100.0);
?
then "checkpoint1" would be my checkpointid?
Reply

Quote:
Originally Posted by ******
Посмотреть сообщение
Or you could just write a new function to wrap "valstr" and return a string (bear in mind that you will need a string at least 12 cells long to handle all numbers)..
Yes, that's what I did, but I wanted to know if there was a faster way (e.g. using advanced macros) to convert, however it seemed unlikely. Thanks anyway.

Edit: Disregard the question that was here. Apparently you can't convert like in C# where you could do
pawn Код:
str[0] = (char)(3 + '0');
and str[0] would then be '3'. But why is that, actually? I hate that you can't do that in PAWN.
Reply

i have problem when i complected my Gamemode
Quote:

(19844) : error 001: expected token: ";", but found "-identifier-"

Code:
Line >> 	eastlobby1 = CreateDynamicObject(1536,253.14941406,110.59960938,1002.21502686,0.00000000,0.00000000,270.00000000,-1,10,-1,100.0); // East lobby door (moves north)
Reply

That error means that you forgot a ; on one of the linies, probably the line before the one where the error points at.
Reply

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
That error means that you forgot a ; on one of the linies, probably the line before the one where the error points at.
Thanks Alot
+rep
Reply

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Edit: Disregard the question that was here. Apparently you can't convert like in C# where you could do
pawn Код:
str[0] = (char)(3 + '0');
and str[0] would then be '3'. But why is that, actually? I hate that you can't do that in PAWN.
You know you can just do this, instead of the above? This will work perfectly fine in Pawn:

pawn Код:
str[0] = 3 + '0';
Reply

AFter adding the CMD i have one problem When people have mask they lose it of they relogged And
When people talk in /b or /s or /l or anything their name still, it's not changed to Stranger..
Can you edit it?

pawn Код:
new GiveMask[MAX_PLAYERS]; // Top of script
new MaskOn[MAX_PLAYERS]; // Top of script

//Commands can be anywhere except not in call backs like OnPlayerCommandText, or OnPlayerSpawn.

CMD:givemask(playerid, params[])
{
    new targetid;
    if(IsPlayerAdmin(playerid))
    {
        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "USAGE: /givemask [playerid]");
        else if(targetid == INVALID_PLAYER_ID) SendClientMessage(playerid, -1, "Player not online !");
        else
        {
            if(GiveMask[targetid] == 1)
            {
                SendClientMessage(playerid, -1, "Player already has a mask!");
            }
            else
            {
                GiveMask[targetid] = 1;
            }
        }
    }
    else return SendClientMessage(playerid, -1, "You're not authorized to use this command !");
    return 1;
}

CMD:mask(playerid, params[])
{
    if(GiveMask[playerid] == 1)
    {
        if(MaskOn[playerid] == 0)
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    ShowPlayerNameTagForPlayer(i, playerid, 0);
                }
            }
            MaskOn[playerid] = 1;
            SendClientMessage(playerid, 1, "* You've put your mask on!");
        }
        else if(MaskOn[playerid] == 1)
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    ShowPlayerNameTagForPlayer(i, playerid, 1);
                }
            }
            SendClientMessage(playerid, 1, "* You've put your mask off!");
            MaskOn[playerid] = 0;
        }
    }
    return 1;
}
[/quote]
Reply

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
You know you can just do this, instead of the above? This will work perfectly fine in Pawn:

pawn Код:
str[0] = 3 + '0';
Holy. Mother. Of. God. I'm retarded. No really, I am. Cheers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)