Little coding questions - For general minor queries 5

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Is it possible to make a function with an arg which accept 2 type like string & integer ?
Do you mean something like use the same arg for both string and integer, or integer and string?

PHP код:
example(intstring[])
{
    return 
1;

Or this?
PHP код:
example(string[])
{
    if(!
strval(string))
        print(
"Arg is a string.");
    else
        print(
"Arg is an integer");
    return 
1;

Reply

Quote:
Originally Posted by Jeroen52
Посмотреть сообщение
Do you mean something like use the same arg for both string and integer, or integer and string?

PHP код:
example(intstring[])
{
    return 
1;

Or this?
PHP код:
example(string[])
{
    if(!
strval(string))
        print(
"Arg is a string.");
    else
        print(
"Arg is an integer");
    return 
1;

The same arg with two types like Function(code[]/Float:code) and you can use 'code' as a Float and a string.
Reply

I can't give the detail, what's happened on my gamemode. First, I register to the server. Then, it's all ready done. I logged in. Successfully, all worked. I try to reconnect, then I login. It's done, successfully. The second try, I login. After login, I alt-tab then I GMX my server from the VPS. After that, I got "Server Closed Connection" as always because I did GMX.

After GMX, I re-connecting again. Then I got "Incorrect Password" after that. But I'm sure, I'm not fill the wrong password because my password is just "123456". I dont know what's happened, and what's wrong on my server. I used DINI, because i'm newbie then I have to learn about saving system and others. The DINI is very simple and recommended for beginner scripter.
Reply

I'm trying to fetch alphabets according to their IDs and I know it's possible but how can I do that? is there something that I can use?

PHP код:
new aID 5// holds the alphabet ID;
printf("%c is where the bomb is."GetAlphabet(aID)); 
So this'll print 'F' as letter F is 5, letter A is 1 and letter Z = 25.

---

I've a object which moves under some specific conditions and it's in the sky but it falls and comes to the ground and/ or destroys. What's must be causing it? Any guesses?
Reply

Quote:
Originally Posted by Logic_
Посмотреть сообщение
I'm trying to fetch alphabets according to their IDs and I know it's possible but how can I do that? is there something that I can use?

PHP код:
new aID random(25 1) + 1// holds the alphabet ID;
printf("%s is where the bomb is."GetAlphabet(aID)); 
---

I've a object which moves under some specific conditions and it's in the sky but it falls and comes to the ground and/ or destroys. What's must be causing it? Any guesses?
I'm not quite familiar what you put in "alphabet" id's - could you try explain what it should, because i didn't get it
Reply

Quote:
Originally Posted by Logic_
Посмотреть сообщение
I'm trying to fetch alphabets according to their IDs and I know it's possible but how can I do that? is there something that I can use?

PHP код:
new aID 5// holds the alphabet ID;
printf("%c is where the bomb is."GetAlphabet(aID)); 
So this'll print 'F' as letter F is 5, letter A is 1 and letter Z = 25.

---

I've a object which moves under some specific conditions and it's in the sky but it falls and comes to the ground and/ or destroys. What's must be causing it? Any guesses?
http://www.asciitable.com/

Each character has a numerical value.

string[0] = 'F' would be the same as doing string[0] = 70, however lowercase and uppercase letters have different values.

So theoretically:
PHP код:
GetAlphabet(alphaiduppercase false)
    return (
uppercase) ? (alphaid 65) : (alphaid 97); 
Код:
printf("%c %c %c %c", GetAlphabet(6), GetAlphabet(6, .uppercase = true), GetAlphabet(22), GetAlphabet(22, true));
Would print:
Код:
f F v V
And F would be the 6th letter of the alphabet, not 5th. This function starts at index '0', where 'A' is 0, 'B' is 1, etc. If you want to change this so A is index 1, all you need to do is replace '+ 65' and '+ 97' with '+ 64' and '+ 96'.
Reply

This is not possible?
PHP код:
InfoOOC(const playeridmessage[], va_args<>)
    return 
Info(playeridINFO_OOC_messageva_args); 
Reply

Try to figure how to fix this since 1 month.

Issue:

Enum datas are getting mixed up together or simply assigning random values.

Examples:

- Password variable mixing up with Zone[100] variables. Thus, from debugging, i found out why the password weren't matching. Found out that it was setting the password typed to "Blueberry Acres".

- readcmds value auto-sets to true when a player logs.

What i tried to fix the issue:

- Resetting all the variables when the player logs in/out.

- Used a seperate enums for other datas (E_PLAYERDATA enum for basic vars and E_OtherInfos for other infos for decreasing the variables on E_PLAYERDATA)

__________________________________________________ _______________________________________________

Nothing worked, i thank you in advance if you found a fix for it. Code is below!

PHP код:
enum E_PLAYERDATA
{
    
ID,
    
Password[65],
    
Salt[15],
    
VIP,
    
Kills,
    
Deaths,
    
aDate,
    
bool:UnderCover false,
    
bool:readcmds false,
    
bool:readpms false,
    
Zone[100],
    
LoggedIn,
    
BankCash,
    
BribesAccepted
};
new 
pInfo[MAX_PLAYERS][E_PLAYERDATA]; 
Reply

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Sounds like memory corruption, what includes and plugins do you use?
I use these:

PHP код:
#include <a_samp>
#include <i-zcmd>
#include <sscanf2>
#include <a_mysql>
#include <foreach>
#include <streamer>
#include <line> 
Reply

how can i add more then 1 object id to
Код:
if(IsValidObject(objectid))
also is it possible to add the specif pos for the object in IsObjectValid and DestroyObject?? so that it only destroys that object and not one whit the same id on the other side of the map?

Thanks in advance
pm me if you need need more info on the script
Reply

Quote:
Originally Posted by noPANDA
Посмотреть сообщение
difference between
if(somethinghere)
and
if(!somethinghere)?
if(something)
used for a bool var (and also null intr)and if something is true it will be called
and !something is false

so :

they are same like

if(somethinghere) => if(somethinghere == true)
&
if(!somethinghere) => if(!somethinghere == false)
Reply

Quote:
Originally Posted by noPANDA
Посмотреть сообщение
difference between
if(somethinghere)
and
if(!somethinghere)?
PHP код:
if(somethinghere//If the value is true 
PHP код:
if(!somethinghere//If the value is false 
Reply

guys i know its basic one but i realy want to know

is any different between null and 0 ?
Reply

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
Depends on the language..
i mean if it is possible to check if is a varb null(with out any data defined) or 0
Reply

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
There's no such thing in Pawn. All variables are 32 bits wide and have a default value of 0. There are also no pointers in Pawn so there's no need for a null value.
aha thanks
Reply

Removed.
Reply

What's better: every player with his timer or a single timer with a loop inside?
Reply

Quote:
Originally Posted by GaByM
Посмотреть сообщение
What's better: every player with his timer or a single timer with a loop inside?
Per-player timers, but they can be spammed through hacks.
Reply

Quote:
Originally Posted by Logic_
Посмотреть сообщение
but they can be spammed through hacks.
What do you mean?
Reply

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Per-player timers, but they can be spammed through hacks.
https://sampwiki.blast.hk/wiki/SetTimer
  • Timer intervals are not accurate (roughly 25% off). There are fixes available here and here.
  • Timer IDs are never used twice. You can use KillTimer() on a timer ID and it won't matter if it's running or not.
  • The function that should be called, must be public, meaning it has to be forwarded.
  • The use of many timers will result in increased memory/cpu usage.
Wasn't using more efficient to use a single timer with a loop inside?
Besides, Pawn is single-threaded anyways so the timers don't run on a separate thread.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)