Little coding questions - For general minor queries 5
#21

Read the first page.. There's a link to old topics from this..
Reply
#22

What would be the easiest way to create a poker script?
I need to define all the cards at least, but how to make so that the cards will be randoms for every player?

Just give me the functions i need, and I'll try to set it up on my own.

Regards, Thom
Reply
#23

You'd have to write all your own functions to do this basically... cus you need to make sure that the players only get cards which are still in the pack etc. You'll need an array of all the cards etc. There's actually a few tutorials for c++ etc which explain how this could be done on the internet.. you'd just need to get the idea of what needs to happen and convert it to pawn basically
Reply
#24

Quote:
Originally Posted by !damo!spiderman
You'd have to write all your own functions to do this basically... cus you need to make sure that the players only get cards which are still in the pack etc. You'll need an array of all the cards etc. There's actually a few tutorials for c++ etc which explain how this could be done on the internet.. you'd just need to get the idea of what needs to happen and convert it to pawn basically
Thanks.

I've got another question.
What would be the closest function to force someone to use filterscript ( or something similiar )
Reply
#25

Force someone to use it? As in load it with the gamemode?

You can use SendRconCommand() and send the string "loadfs <insert your fs name here>"
Reply
#26

Thanks spiderman, that helped a lot. I'll add it, and figure out how to get it working.

The reason why i wanted to force someone to use filterscript was, well this might sound pretty stupid since there's probably an easier way, but i wanted so that OnPlayerDeath the player will be forced to use CAM, which is a filterscript made for spectating.
Just was too lazy to create my own lol

Regards, Thom.
Reply
#27

im having trouble using GetPlayerWeapon.
weaponid = GetPlayerWeapon(playerid)
if (weaponid = 35)
{
SendClientMessage(playerid,COLOR_RED,"TEST");
}
but it says the weaponid = line is an invalid function or decleration and the same for l the if (weaponid = 35) line
any examples of how GetPlayerWeapon is used?
Reply
#28

Quote:
Originally Posted by MATT11504
im having trouble using GetPlayerWeapon.
pawn Code:
weaponid = GetPlayerWeapon(playerid)
if (weaponid = 35)
{
SendClientMessage(playerid,COLOR_RED,"TEST");
}
but it says the weaponid = line is an invalid function or decleration and the same for l the if (weaponid = 35) line
any examples of how GetPlayerWeapon is used?
pawn Code:
if (weaponid == 35)
Shouldn't it be like that?
Reply
#29

Is there a function I can use to clone a file, but change the file name, useful for cloning players that change name ingame.
Next, is there a delete file function in PAWN?
Reply
#30

No, it's usually quicker to just ask. Seeing as people here usually reply quite quick.
Reply
#31

Is there a way I can create a byte variable? In VB it's
Code:
Dim ByteVar As Byte
but I don't know how to do it in Pawn.

It might be an easy thing to figure out but I can't for some reason. Searching pawn-lang.pdf atm. Wiki has no documentation on single byte variables.
Reply
#32

Quote:
Originally Posted by Pixels^
Is there a way I can create a byte variable? In VB it's
Code:
Dim ByteVar As Byte
but I don't know how to do it in Pawn.

It might be an easy thing to figure out but I can't for some reason. Searching pawn-lang.pdf atm. Wiki has no documentation on single byte variables.
Pawno is a typeless language, all variables are the same size. If you want to create a byte then you can split a cell into four bytes and do some binary manipulation (binary and/or/xor). There's a set of symbols that can do the binary manipulation for you (it's precompiled) as a char for packed strings.

pawn Code:
new MyString[20 char] = !"aavi: Hey listen!";

MyString{0} = 'N';
Search for packed strings in pawn-lang.pdf, you could possibly use them like bytes.
Reply
#33

Is it possible to use a variable in a filterscript that is set in another (compiled) filterscript or a gamemode script?

Like this:

[code=Filterscript 1.pwn]
#include <a_samp>

gPlayerMoney[playerid];

public OnPlayerConnect(playerid)
{
gPlayerMoney[playerid] = 50000;
}
[/code]

[code=Filterscript 2.pwn]
#include <a_samp>

extern gPlayerMoney[playerid]; // maybe replace extern with a special declaration?!

public OnPlayerDeath(playerid)
{
gPlayerMoney[playerid] =- 1000;
}
[/code]

EDIT: Just found a workaround... Saving the variable to a File and then reading it from the other Filterscript...
Reply
#34

Files are overkill, use CallRemoteFunction on a special function that gets or sets the variable to a specific value.
Reply
#35

Quote:
Originally Posted by Pixels^
CallRemoteFunction
Thats what I was looking for! Thanks!
Reply
#36

Can you help me:

new float:health;
GetPlayerHealth(killerid,health);
SetPlayerHealth(killerid,health +50);

The compiler is saying Tag mismatch

it is supposed to kive the killer 50 live back if he kills someone.

//I Just had to write float with a capital letter
Reply
#37

I was wondering if there is a more efficient way to check the value of a variable: i (i is used in a for loop).

I am currently doing this:
pawn Code:
for(new i = 0; i <= MAX_PLAYERS; (i != playerid) ? i++ : i += 2)
{
  print("Simon is a nubzorz."); // Not actually doing this, but w/e.
}
This gives me the following errors:
Code:
C:\PROGRA~1\ROCKST~1\GTASAN~1\Samp\GAMEMO~1\para.pwn(263) : error 022: must be lvalue (non-constant)
C:\PROGRA~1\ROCKST~1\GTASAN~1\Samp\GAMEMO~1\para.pwn(263) : warning 215: expression has no effect
C:\PROGRA~1\ROCKST~1\GTASAN~1\Samp\GAMEMO~1\para.pwn(263) : error 001: expected token: ";", but found ")"
C:\PROGRA~1\ROCKST~1\GTASAN~1\Samp\GAMEMO~1\para.pwn(263) : error 029: invalid expression, assumed zero
C:\PROGRA~1\ROCKST~1\GTASAN~1\Samp\GAMEMO~1\para.pwn(263) : fatal error 107: too many error messages on one line

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


4 Errors.
Line 263 is the for() line.

I know you can simply check with a continue statement, but I wondered if there was a 'safer' way.

The .pdf said that the variable must be non-constant, so that it can be modified, so I wasn't sure how that variable was not constant.

I did try asking on IRC, but it appeared that everybody was busy, idling, or perhaps just ignoring me

Thanks in advance,

~Cueball~
Reply
#38

I just answered on irc but I'll answer here too so people can reference it later

pawn Code:
for( new i = 0; i < MAX_PLAYERS; (i==2) ? (i++):(i+=2)){}
You'll get a Warning about expression having no effect but it can be ignored
Reply
#39

Thanks damo, I also tried that (placing the possible options in brackets), but I did recieve the warnings, so I moved on. Now it seems that I will be stuck with the warnings, so I'm wondering if there is a way to compile cleanly with this method (not using a continue statement)?

Thanks again,

~Cueball~
Reply
#40

pawn Code:
for( new i = 0; i < MAX_PLAYERS; i=(i==2) ? (i++):(i+2))
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)