AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   2 questions.. pfn_touch and model sequences (https://forums.alliedmods.net/showthread.php?t=20275)

oberon 11-05-2005 10:41

2 questions.. pfn_touch and model sequences
 
2 Attachment(s)
q1: pfn_touch called, then one of touching entities isnt found when u do something to it throwing a "Cannot find entity" error

i'm making a checkpoint mod for uwc3 (cs), where bomb/hostages are removed from the map, and instead 3-5 checkpoints are spawned into the map, and if one team controls all the checkpoints, the other team have X seconds to recapture a point or they all get slayed.

I got it working fine (no errors) on a test server on my machine with 5 players, and loads of bots... then when i moved it to one of our real servers, bits didnt work, and after adding debug, this line is causing the "cannot find entity" error was line 487 (attached sma below):

Code:
entity_get_string( iToucherId, EV_SZ_classname, szClassName, 31 )

from:

Code:
//---------------------------------------------------------------------------------------------- public pfn_touch( ptr, ptd ) {     return on_Touch( ptr, ptd ) } //---------------------------------------------------------------------------------------------- public on_Touch( entity1, entity2 ) {     if(get_cvar_num("cp_enable") == 0) return PLUGIN_HANDLED         // Make sure it's a player that's being touched... mmmm     new iToucherId = entity1     new iPlayerId  = entity2         if ( iPlayerId < 1 || iPlayerId > 32 || iToucherId < 1 || !is_user_alive( iPlayerId ) )         return PLUGIN_CONTINUE         new szClassName[32]     entity_get_string( iToucherId, EV_SZ_classname, szClassName, 31 )         // Change checkpoint's team     if ( equali( szClassName, "CHECKPOINT" ) ) {             // Change Checkpoint to iPlayerId's team etc etc etc

and yet stuff that can only happen if the szClassName is "CHECKPOINT" happens, even tho it cant find the entity. The checkpoint changes model to the right colour, but the xp isnt given (or even a msg to indicate that the xp function was called).

I've attached the sma, and the models (need to be in the models/uwc3_cp folder).. if anyone is bored and wants to try compiling it u wont need uwc3, just when it awards xp, it'll be 0 :)

q2: the letter models attached have one sequence, idle which is the letter spinning 360 degrees on the spot. yet when i add the model in game, its static.

I was told the following would do the trick, but i tried 0 - 6 for the sequence number, and couldnt get it to work:

Code:
entity_set_int(iEnt, EV_INT_sequence, 0)

cheers in advance

Hawk552 11-05-2005 10:45

Try
Code:
if ( iPlayerId < 1 || iPlayerId > 32 || iToucherId < 1 || !is_user_alive( iPlayerId ) || !is_valid_ent(iToucherId) )

Bend3R 11-05-2005 11:47

nice models, have would be good to my server with my name lol :)
If it was N R models in it too

XxAvalanchexX 11-05-2005 14:30

About your code, Hawk. Firstly, if a server's max slots is 8, then a non-player entity could have an index of 9, so the > 32 check is useless. Secondly, is_user_alive already checks if the player is connected, so you can just remove the < 1 and > 32 checks entirely and leave is_user_alive in there. Thirdly, why do you check to see if the other entity's index is > 1 and then use is_valid_ent? Scrap the > 1 check and just use is_valid_ent, it won't explode of the entity is 0.

Hawk552 11-05-2005 14:58

All I did was add !is_valid_ent. If you actually read his post, you would see he put that stuff.


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

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