Little coding questions - For general minor queries 5

Thank you guys, but now there's another small question.What is difference between () and [].Let's say we creating register/login system, so we need logged variable, and we are writing it with playerid, so it looks like that:logged[playerid].So playerid checks player id and finds it, but why we can't write it like this- logged(playerid)?
Reply

Because the brackets ([]) are used to reference an index in an array. While parenthesis are used for functions. Kinda hard to explain.
Reply

Quote:
Originally Posted by Backwardsman97
View Post
Because the brackets ([]) are used to reference an index in an array. While parenthesis are used for functions. Kinda hard to explain.
But when to know when to put these "[]" or these "()"?
Reply

Is it possible to set an "optional" parameter at a function? Just like the DrawDistance at CreateObject() is optional and has a default value if not set.
Reply

How do I make all the players in a team move faster than normal ?
Reply

Quote:
Originally Posted by Hiddos
View Post
Is it possible to set an "optional" parameter at a function? Just like the DrawDistance at CreateObject() is optional and has a default value if not set.
https://sampforum.blast.hk/showthread.php?tid=186616
Reply

Quote:
Originally Posted by ******
Посмотреть сообщение
Look for CreateVehicle, AddStaticVehicle and AddStaticVehicleEx, those are all the vehicle creation commands.
I delete all that but still i've got cars in script
Reply

Then you have an FS/include that creates vehicles in the server.

EDIT:
Is there any SoundID that I can use with PlayerPlaySound that will play the sound of an explosion?
Checked the wiki but couldn't find an explosion sound.
Reply

Wondering how I could script a private messaging system with a key? Like when player presses something it brings a dialog or something to type id/playername and then message to the ID.
Reply

How to stock SetTimerEx

pawn Код:
stock Test_SetTimerEx(funcname[], interval, repeating, const format[], {Float,_}:...)
{
SetTimerEx(?)
}
Reply

Quote:
Originally Posted by NiZ
Посмотреть сообщение
Wondering how I could script a private messaging system with a key? Like when player presses something it brings a dialog or something to type id/playername and then message to the ID.
With OnPlayerKeyStateChange and ShowPlayerDialog - DIALOG_STYLE_INPUT

Quote:
Originally Posted by RAEN
Посмотреть сообщение
How to stock SetTimerEx

pawn Код:
stock Test_SetTimerEx(funcname[], interval, repeating, const format[], {Float,_}:...)
{
SetTimerEx(?)
}
you could do it with numarg and getarg but thats a lot of effort and a waste

Why do you need a SetTimerEx stock ?
Reply

how can i get attachedobjecttovehicle position?
Reply

Quote:

you could do it with numarg and getarg but thats a lot of effort and a waste

Why do you need a SetTimerEx stock ?

To Debugged when the timer is start etc... Because sometimes my sever is shutdown, and I can't find the problem.
Reply

Quote:
Originally Posted by RAEN
Посмотреть сообщение
To Debugged when the timer is start etc... Because sometimes my sever is shutdown, and I can't find the problem.
You could just do a print or something?

pawn Код:
// Wherever you are calling the timer.
SetTimer("TestMessage", 5000, false); // or SetTimerEx if you need params.
print("Timer started. (#TestMessage)");

// Your callback
forward TestMessage();
public TestMessage()
{
    print("Timer done, callback called. (#TestMessage)");
}
Reply

Why when I script something with dialogs I get errors "Undefined symbol ShowPlayerDialog" and "Function lacks forward declaration "OnDialogResponse."?
Reply

Download the latest server package with the newest includes
Reply

Quote:
Originally Posted by Tupac
View Post
will pvars work in 2 scripts at once? gm/npcmode
yes, if you use SetPVarInt(playerid,"test",2; in one script you can use GetPVarInt(playerid,"test"); in another script and it'll return the value you set in the first script
Reply

Is there a way to reverse words? So to check if a player typed a word reversed...
Reply

Quote:
Originally Posted by knackworst
View Post
Is there a way to reverse words? So to check if a player typed a word reversed...
Sure, here you go:
pawn Code:
stock ReverseText(szText[]) {
    for(new i = 0, j = strlen(szText) - 1; i < j; ++i, --j) {
        szText[i] ^= szText[j], szText[j] ^= szText[i], szText[i] ^= szText[j];
    }
}
Reply

Looks pretty neat ty, but what is the outputstring?
Reply


Forum Jump:


Users browsing this thread: 10 Guest(s)