Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2012-10-24 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog
Chat

War3:Source
October 24, 2012, 03:25:15 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Download: http://war3source.com/index.php?board=9.0
What is War3Source?: http://war3source.com/index.php?topic=200.0
Sample Stats: http://war3source.com/war3stats
Steam Community Group: http://steamcommunity.com/groups/war3source
War3Source SVN Checkout: http://ownageclan.com/svn/war3source/
War3Source servers: http://www.game-monitor.com/search.php?vars=war3_version=
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Setting the entity model of a player.  (Read 350 times)
Vulpone
Full Member
***
Posts: 140



View Profile Email
« on: July 26, 2011, 04:40:53 PM »

Greetings,

it's me again!
Currently working on a fun race that let's you play as the Master Chief from Halo! I even got models for his pistol, his assault rifle & his Energy Sword. But that's not the issue.

What's really.. well, bothering me is the following. Take a look at the code.

Code:
public OnWar3EventSpawn(client)
{
new race=War3_GetRace(client);
if( race == thisRaceID)
{
if(ValidPlayer(client, true))
{
new team = GetClientTeam(client);
GivePlayerItem(client,"weapon_deagle");
GivePlayerItem(client,"weapon_p90");
GivePlayerItem(client,"weapon_knife");
if( team == 3)
{
SetEntityModel(client, "models/player/bic/ct_sas.mdl");
}
else if( team == 2)
{
SetEntityModel(client, "models/player/bic/t_arctic.mdl");
}
}
}
}

The weird thing is, both ARE working models. Completely.
However, it SETS the models for terrorist. It doesn't do it for the counter-terrorist, though. Both models have been tested.
I once reverse the models (gave the CT the red one and the T the blue one) - the Terrorist was a blue chief. The CT still did not have any model.

Now, I've been searching through some races, including a lot of TCs work, as he uses a LOT of models, and I compared them to mine.
I still couldn't find the error.

I was under the impression that GetClientTeam(client) is T if it returns 2, CT if it returns 3, Spectator if it returns 1.

I'd greatly appreciate your help.
I'd love to release this Master chief once I'm done with it. (Finding the models for the guns took me quite some time, some luck and an open svn ;d; also, I'll try to implement the Shield (got the sounds) that automatically recharges if the client is not taking damage.)

Once again, I thank you in advance,
Vulpone
Logged

Sapere aude!
[Oddity]TeacherCreature
Sr. Member
****
Posts: 463


View Profile
« Reply #1 on: July 26, 2011, 05:48:28 PM »

Change this:
else if( team == 2)

to this:
if(team==2)


or better yet
put the GetClientTeam(client)  into the line instead of makign a new variable that is not needed, nesting is a beautiful thing
Logged

Vulpone
Full Member
***
Posts: 140



View Profile Email
« Reply #2 on: July 26, 2011, 06:45:50 PM »

Well, I don't share your opinion on nesting - I believe a code should be able to be read as a story is.
And by replacing huge nests by one single name, I save time, make the code easier to read, and keep it clean. Besides, commenting it becomes less necessary (unless functions actually get moar complicated).

Other than that..Testing your proposal now.

Not working. Did as you told me, yet the CT one STILL isn't modeled - it's the normal CT skin.

Code:
public OnWar3EventSpawn(client)
{
new race=War3_GetRace(client);
if( race == thisRaceID)
{
if(ValidPlayer(client, true))
{
if(GetClientTeam(client) == 3)
{
SetEntityModel(client, "models/player/bic/ct_sas.mdl");
}
if(GetClientTeam(client) == 2)
{
SetEntityModel(client, "models/player/bic/t_arctic.mdl");
}
}
}
}

But that's it for today.
Time to get some sleep, perhaps I'll get something working tomorrow, though it's odd this isn't working.
Logged

Sapere aude!
[Oddity]TeacherCreature
Sr. Member
****
Posts: 463


View Profile
« Reply #3 on: July 27, 2011, 06:08:16 AM »

ok well then test perhaps ur model isnt loaded...
Set your model as a string
new String:BLAH="path";

then in each team instance put a message to self and print the BLAH string and see if it is tryign to set it....
If it isnt ur not processing if it is ur model isnt loaded right.

I meant I like to nest so I dont have more unecessary variables in the code thats it
Logged

Glider⠠⠵
Global Moderator
Sr. Member
*****
Posts: 413


⠠⠵


View Profile
« Reply #4 on: July 28, 2011, 11:52:44 AM »

Just gonna throw this page about optimizing in here. Getting used to writing like that is a pretty bad habit imho.

But yeah, put some PrintToChatAll in there to check what's happening and check if the models are correctly preloaded and stuff.
Logged

Vulpone
Full Member
***
Posts: 140



View Profile Email
« Reply #5 on: July 29, 2011, 04:37:41 PM »

After a lovely book about C, reminding me to save ANY kb I can, I believe I can handle it Cheesy
Besides, I re-wrote the code several times before posting here. The final one I came up was an extra-careful one (you know, "just to be safe").
Anyways.. my first take at this was using a new string, as I need to re-set the models later on (I change to different models while cloaked, I'll see how that works out).
I just could not yet find the error. I tried the string, I exchanged the T/CT models etc. The models were always correct, yet the CT one was never loaded.

I'll take a look at this tomorrow; just came back from a few days of vacation and I'm too exhausted to even think about that now.

I am, however, grateful for your time and help!
Logged

Sapere aude!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!