AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with the "If" statement (https://forums.alliedmods.net/showthread.php?t=25741)

Skeetles 03-19-2006 14:11

Help with the "If" statement
 
I feel like an idiot asking this question, but obviously I am not getting it right. PAWN must be different from VB and Java, here are my if statements that get 4 errors and 2 warnings.
Code:

if(get_cvar_num("amx_rpgbuy")="0")
Code:

if(omfg<4500)
//omfg = cs_get_user_money
Code:

if(hasRPG[id]=1 && nrop = "CSW_AWP")
Everything else should work and I am only getting errors/warnings on these three lines.

teame06 03-19-2006 14:16

Code:
if(get_cvar_num("amx_rpgbuy") == 0)

Code:
if(hasRPG[id]=1 && equal(nrop, "CSW_AWP"))


Code:
if(omfg<4500)
Doesn't look like anything wrong here .. But you might of used the native wrong and giving you the error...


PS. Next Time give the error to

jtp10181 03-19-2006 14:17

= is for assignment and == is for comparison
the second one is totaly fine
the third... you cannot compare strings using = (or == for that matter), check the string.inc

Skeetles 03-19-2006 14:26

Ok it all works except for this line:
Code:
    if(hasRPG[id]==1 && equal(nrop, "CSW_AWP"))
Argument type mismatch, argument 1

I guess I should have said
Code:
new nrop = cs_get_weapon_id (id)
but it still looks like it should work.

Skeetles 03-19-2006 15:06

What does cs_get_weapon_id return exactly? that might be the problem, sorry for the double post.

wouter 03-19-2006 15:09

think it returns
Code:

CSW_P228
CSW_SCOUT               
CSW_HEGRENADE               
CSW_XM1014               
CSW_C4                       
CSW_MAC10               
CSW_AUG                       
CSW_SMOKEGRENADE       
CSW_ELITE               
CSW_FIVESEVEN               
CSW_UMP45               
CSW_SG550               
CSW_GALI               
CSW_GALIL               
CSW_FAMAS               
CSW_USP                       
CSW_GLOCK18               
CSW_AWP                       
CSW_MP5NAVY               
CSW_M249               
CSW_M3                       
CSW_M4A1               
CSW_TMP                       
CSW_G3SG1               
CSW_FLASHBANG               
CSW_DEAGLE               
CSW_SG552               
CSW_AK47               
CSW_KNIFE               
CSW_P90


Skeetles 03-19-2006 15:19

I am so glad I realised this, new wpnid = read_data(2)
cs_get_weapon_id won't work in this situation.

jtp10181 03-19-2006 22:27

so....? you got it all working?

VEN 03-20-2006 04:26

CSW_AWP is integer constant which defined in includes so nrop must be integer either and then that operation would be correct: nrop == CSW_AWP

If you want get current weapon id, use get_user_weapon
cs_get_weapon_id is for weapon entity id


All times are GMT -4. The time now is 16:39.

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