Raised This Month: $51 Target: $400
 12% 

Help a beginner - Entities and such


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pilger
Senior Member
Join Date: Sep 2010
Old 09-03-2010 , 10:39   Help a beginner - Entities and such
Reply With Quote #1

Hey guys,

I'm all new to this Pawn scripting thing, although i have a vast experience with PHP and even some with Ruby scripting. I'm attempting to write TF2 plugins now.

I've managed to fetch some basic and simple info from the server, like the user connection time with GetClientTime() but couldn't move much further.

So i guess i got the way of the basic and compiling but i can't really understand where do you guys take and set all the info on the server. I have no clue of how to use those entities and stuff.

How can i, for instance, fetch the players score, class, team score and stuff like that. I'm not looking for done stuff. I want to understand how it works.

Can someone give me some assistance?

Thanks!
pilger is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 09-03-2010 , 10:45   Re: Help a beginner - Entities and such
Reply With Quote #2

http://docs.sourcemod.net/api/

Use that to find the basic commands at your disposal.
You'll need to look around at first, because you probably don't know where which command is stored, so just use search
For example, if you'd need a command to get a team's score, type "Score" in search.

Some changes are more advanced, (Propdata and the likes) but you can search plugins that do affect them to learn how to do it.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
spunkster21
Senior Member
Join Date: Aug 2008
Old 09-03-2010 , 11:47   Re: Help a beginner - Entities and such
Reply With Quote #3

Additionally, it would be very beneficial to go through the various tutorials here.

Once you do that, I'd suggest thinking up some basic plugin ideas and then scripting them up to see how you get along. There will be many plugins that already do what you're after, which you can use to better understand how things work.
spunkster21 is offline
pilger
Senior Member
Join Date: Sep 2010
Old 09-03-2010 , 12:11   Re: Help a beginner - Entities and such
Reply With Quote #4

Well, i'm actually sort of a "good beginner", so i've looked through all that before asking for help. Google didn't work much either.

The thing that bothers me most is the lack of (proper) documentation. Sometimes the function's description just say what it does but it's not very clear and it doesn't have any example. I gets hard for beginners to understand what they actually do and how.

One of my main questions is: does everything work the same for every game? Do i have specific TF2 stuff or they're just the same as CS and L4D? What are the indexes that appear on the documentation all the time? I've tried numbers, figuring they'd work as arrays, but it didn't quite work.

I actually got stuck trying to fetch the player's score and didn't move much forward. I looked briefly and the other info seems fairly easy to fetch.

I'm gonna try some more when i get home tonight and then i'll explain my doubts more specifically.

Thanks!
pilger is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 09-03-2010 , 12:43   Re: Help a beginner - Entities and such
Reply With Quote #5

Quote:
Originally Posted by pilger View Post
Well, i'm actually sort of a "good beginner", so i've looked through all that before asking for help. Google didn't work much either.

The thing that bothers me most is the lack of (proper) documentation. Sometimes the function's description just say what it does but it's not very clear and it doesn't have any example. I gets hard for beginners to understand what they actually do and how.

One of my main questions is: does everything work the same for every game? Do i have specific TF2 stuff or they're just the same as CS and L4D? What are the indexes that appear on the documentation all the time? I've tried numbers, figuring they'd work as arrays, but it didn't quite work.

I actually got stuck trying to fetch the player's score and didn't move much forward. I looked briefly and the other info seems fairly easy to fetch.

I'm gonna try some more when i get home tonight and then i'll explain my doubts more specifically.

Thanks!
Some functions are mod-specific, but those should be quite obvious (like CS_SwitchTeam and TF2_AddCondition... guess what they're for? :p).
Other functions should be global. Although some games have problem dealing with some of them, because it simply isn't supplied in their gameplay.

And about your player score problem: That's one of those things you'll need to learn from example at first, as it deals with offsets and entdata.
Examples: These two set a client#'s frags and deaths.
PHP Code:
SetEntProp(ClientProp_Data"m_iFrags"varFragCount);
SetEntProp(ClientProp_Data"m_iDeaths"varDeathCount); 
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.

Last edited by Monkeys; 09-03-2010 at 12:45.
Monkeys is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 09-04-2010 , 09:09   Re: Help a beginner - Entities and such
Reply With Quote #6

GetClientScore?

As for the entities, start server, open console, sv_cheats 1, cl_showents, there, you have it.
FaTony is offline
pilger
Senior Member
Join Date: Sep 2010
Old 09-04-2010 , 09:29   Re: Help a beginner - Entities and such
Reply With Quote #7

@Monkeys

Thanks man. I took a deep breath and sorted it out with patience. It turned out i was doing everything right, but was making a mistake on showing the results. It seems that Pawn is a lot more bitchy about types than PHP or Ruby, so trying to print an Int as a String showed nothing.

@FaTony

I couldn't find such function on the API. I'll try it out when i get home. Although i already got the thing working with that TF2_GetPlayerData or something similar.

And the tip to know all the entities is great. That was actually what i was looking for. Is there a documentation to explain which do what?

I'm getting a little annoying with how arrays work now. But i guess is just a matter of getting used to the language.

Thanks guy!
pilger is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 09-05-2010 , 12:50   Re: Help a beginner - Entities and such
Reply With Quote #8

SourcePawn is more strict to types than C\C++ though the internal mechanisms are absolutely different. You always need to explicitly convert data types (well, one tag into another). As for arrays, SourcePawn directly supports only static arrays and dynamic arrays are done using a handle to adt_array which is a bit slower.
FaTony is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode